So, what is an asteroid and what a comet? They both come from the sky, and they both can potentially cause a damage if they hit Earth.
A comet is an object that is relatively small and appears with a tail when it approaches our sun. An asteroid on the other hand has no tail whatsoever, it orbits our sun but it is not a planet or a moon or a comet.
The comet's tail exists only when the comet is "closer" to a star. That is because the tail is simply the evaporated substances (like water vapors) from the icy frozen object, which glow when photons collide with these particles. In the vacuum of space, liquid substances need only a slight amount of energy to evaporate. The vapors then are carried away by the solar wind, which also explains why the tail extends always away from the star(sun) regardless of the direction of the comet. So do not think the tail as the smoke comming out of a diesel train.
There are though some asteroids that contain water in the form of ice on their surface or below. But
the do not have sufficient ice that can be easily vaporized to form the distinctive tail, thus they remain an asteroid.
Finally, some comets eventually lose all their material that could be vaporized and the rocky core remains in orbit. These objects then are classified as asteroids.