Asteroids orbit the Sun more or less the way the planets do, except mostly in the asteroid belt, which lies between the orbits of Mars and Jupiter. Their orbits are more or less circular, keeping them out of trouble.
Comets have irregular orbits, typically highly eccentric. They spend most of their time far away from the Sun and out of sight. Every so often, their orbits bring them close to the Sun, which boils off volatile material as they approach, resulting in a visible tail. Of course, if they encounter a planet during their close approach to the Sun, the results can be interesting.
I’m talking about composition and construction. Comets obviously are constructed differently to “boil off” a tail, when other objects within similar distances to the sun do not.