Comets are balls of leftover rock and ice in space. They started out when a star exploded into a supernova. A nebula formed, and then most of the material in our nebula merged together, about 4.5 billion years ago.. But these balls didn’t join up with our planets. Instead, the comets kept on circling around the Sun on their own.
Most comets come near Earth just once and then shoot off into outer space. They go out beyond our solar system for thousands of years before they circle back again. A few comets have smaller orbits, staying mostly within our solar system. Some cross Earth’s orbit every year, like Comet Swift-Tuttle. We see Halley’s Comet once every 75 years or so.
When a comet gets close enough to the Earth, some of the smaller rocks that are associated with that comet get sucked into Earth’s gravity. They come falling down to the Earth. We call these meteors. Some comets end up hitting other planets or hitting the Sun. Or they come close enough to Jupiter to be affected by Jupiter’s gravity and whipped out of the solar system like rocks in a slingshot.
When comets get nearer to the Sun, the heat of the Sun warms them up and melts off some of their ice. After about 800 visits near the Sun, the comets are just balls of rock. Many of the asteroids near Earth are old dead comets.
There are probably comets going around other stars as well as our own, but they are too small for our telescopes to see yet.