How is the path of an asteroid calculated? How do scientists and astronomers recognize the perfect path or orbit (if it's orbiting an object) of an asteroid or a comet?
How do scientists and astronomers recognize the perfect path or orbit (if it's orbiting an object) of an asteroid or a comet?


They don't, and they can't. The best they can do is estimate the object's trajectory based on observations and based on techniques used to propagate the object (and other objects in the solar system) over time. These estimates are always imperfect:


The measurements upon which the estimates are based are limited in number. This is particular true for comets and asteroids. The historical record on observations of the Sun and the planets go back thousands of years. The number of observations for a newly observed comet or asteroid might go back a few months.
The measurements upon which the estimates are based inherently have some error associated with them. These measurement errors limit the ability to determine the object's true trajectory.
The physical models used to propagate trajectories are simplified and incomplete versions of reality.


General relativity, our best model of how gravitation works, is exceeding complex and highly non-linear. Even the very best precision orbit determination programs use a linear parameterized post-Newtonian expansion of general relativity. The non-linear effects? They're ignored.
Nearby stars and the galaxy as a whole perturb the trajectories of the Sun, the planets, etc. These effects are ignored.
Comets vent gas when they approach the Sun. When you blow up a balloon and let it go, the balloon veers this way and that. There is no predicting where the balloon will go. Comets do the same thing. After time, there is no predicting where a comet will be or where it is going.
Asteroids (and comets) are subject to radiation pressure, the Yarkovsky effect, and the YORP effect. These are very hard to estimate. One of the key purposes of the upcoming Osiris-REx mission is to get a better handle on the Yarkovsky effect.

The numerical techniques used to propagate objects' trajectories are inevitably flawed to some extent. They introduce errors that grow with time into the propagated trajectories. There's always a tradeoff between precision, accuracy, fidelity to the physics, and computational expense. 
The solar system is ultimately chaotic. This is particularly the case for asteroids and comets on highly elliptical trajectories. Consider a comet whose orbit takes it from beyond Neptune's orbit to inside Venus's orbit. Over the centuries, that comet has ample opportunities to make a close pass with a planet. There are but slight differences between the planet making a minor change in the comet's orbit, the comet colliding into the planet, the planet sending the comet toward the Sun or another planet, or the planet ejecting the comet from the solar system. This is chaos at its worst.