There are many sources of electromagnetic energy in the universe. The different sources emit light essentially for the same reason; they are very hot and glow. The information in this section comes from Universe; although, it can be found in many other places as well.
Hot gases clouds
Hot gases do not start out that way. Hot gases begin as a collection of cool gas molecules or atoms. In one form of heating as the collection of gas gets larger, the atoms and molecules that make up the gas cloud begin to exert stronger gravitational pull on each other. As the gas cloud begins to collapse under the force of gravity, the gas pressure increases and the gas gets hot. As the gas heats, it glows with greater luminosity. Alternatively, some cold gas clouds are heated by trapping escaped radiation from nearby stars.
If a gas cloud has enough mass, it will continue to collapse until there is so much pressure in the center of the star that a thermonuclear reaction begins. The gas cloud begins to "burn" hydrogen. In fact, the hydrogen nuclei are being fused into helium nuclei in a nuclear reaction, rather than being combusted with oxygen in a chemical reaction. When the gas cloud begins to fuse hydrogen nuclei into helium nuclei, the gas cloud is relabeled as a star.
Pulsars are a form of dead star. When a very massive star dies, it becomes a supernova, which basically means that it explodes. However, at the site of many supernovas, a core of material remains. This rotating body has a strong magnetic field and is surrounded by electrons and protons in a plasma. The electrons and protons orbit the star following the star's magnetic field. When the subatomic particles come near the magnetic poles, they speed up and emit light. When the magnetic field does not align with the rotational axis, in a situation similar to that on Earth, the poles of the magnetic field on the star rotate around the star. If the star's rotational axis is conveniently arranged, we see the light emitted by the subatomic particles speeding up as they travel near the magnetic poles. Because we only see the light when the magnetic pole is turned towards us, the light appears to pulse. The phenomenon is similar to watching the valve on a rotating bicycle tire from the perspective of an ant riding on the bottom of the bicycle seat. The ant only sees the valve once every rotation.
Quasar stands for quasistelar radio source. They are immensely luminous and are very distant from us. They tend to be very small for the amount of energy they release. They consist of a massive black hole with an accretion disc around it. As long as the matter in the accretion disc falls into the black hole, large amounts of energy are emitted. The energy emission mechanism is described below.
Accretion disks (around black holes)
When a star is extremely massive, it will collapse into a black hole. A black hole is called a black hole because it contains so much mass that it is able to exert enough gravity that nothing, not even light, can escape it. As a result of no light being emitted from the object, the object appears black. This begs the question: "If we can't see it, how do we know that it is there?" Black holes are visible because matter falling into them emits light. Near a black hole, stars and other matter are being accelerated by the gravitational pull of the black hole. As the gravitation potential is increasing with proximity to the black hole and the total energy of the matter falling into the black hole must remain constant, the matter must emit as much energy as it gains from the gravitational pull of the black hole. The newly acquired additional gravitational potential energy of the matter is converted into kinetic energy and causes the matter to glow. The matter emits light until it falls beyond the event horizon, where gravity is so strong that the light is unable to escape. The luminous disc of matter surrounding a black hole is called the accretion disc.