Comets are chunks made of ice, frozen gases and dust (like dirty snowballs). The come from the outer regions of our solar system. When the get close to the Sun they heat up and evaporate. This evaporating gas and dust is blown away by the solar wind and forms the tails of a comet. Therefore the tail always points away from the Sun. Comets are very common but only a few of them get that close to the Earth that they can be seen with naked eye. See also time lapse movies of comet Neowise C/2020 F3.