What is the the difference between a quasar and a galaxy?
A quasar is an active galaxy.
Most large galaxies, including our own Milky Way, have a supermassive black hole at their centre.
Some galaxies, particularly young galaxies, have large amounts of gas and dust around their centres. This material forms a disc which is spiralling into the supermassive black hole. This disc is called an accretion disc. As more and more material falls into the accretion disc it gets heated by fiction and gravitational effects to the point where it emits vast amounts of energy. This is a quasar.
Quasars can only exist while sufficient material is falling into the accretion disc. Once the material runs out the active galaxy becomes a regular galaxy.
The quasars which have been observed are billions of light years away. This means that they are young galaxies as seen in the early universe.
Related phenomenon are Seyfert galaxies which operate in a similar way to quasars but don't produce so much energy. Any galaxy can ignite as a quasar if sufficient material is available around its central supermassive black hole. This typically happens in young galaxies and when galaxies collide.