For every object in space, it is moving a speed. Planets, asteroids, comets, even stars move across space very quickly. Comets are nothing more than just rock, dirt, and ice. When it moves, the tail is formed due to its movement. It can even be created by water vapor when it goes around a star because it has ice on it.