Quasars are one of the brightest objects in the Universe, they represent a certain stage in the life of galaxies: the so-called galaxies with an active nucleus.
Most galaxies have supermassive black holes in their cores, and in the early stages of a galaxy’s life, these black holes are surrounded by a huge amount of matter that falls onto the black hole in the center. The material falling onto the black hole forms a giant rotating accretion disk. The substance in it experiences friction and due to this heats up to hundreds of millions of degrees.
In this case, the accretion disk generates the brightest radiation, which can be hundreds of times more intense than that of all other stars in this galaxy combined. Such galaxies are called quasars. Quasars were common in the early universe 9-13 billion years ago. At that time, there was much more gas in young galaxies than in current ones, and this gas served as a source of matter for the formation of accretion disks.
Over time, the matter of the accretion disk completely falls onto the black hole, and almost empty space remains around the black hole. The accretion disk disappears, black holes have nothing to absorb, and galactic nuclei cease to be active.
There is evidence that once our galaxy — the Milky Way was once a quasar too. Nowadays, quasars can appear in two cases: when new galaxies are born, or when two old galaxies collide, when the amount of matter near supermassive black holes increases and the nucleus can be re-activated, but in order to talk about the appearance of a quasar, it is necessary not only to be active, but very active core.