Another way to get atoms to emit light is to shine white light on an atom and the electrons would absorb the photon if the energy of that photon was equal to the energy difference between the energy levels. And the electron would jump to the next energy level and be absorbed. All other wavelengths do not have sufficient energy to allow an electron to jump to the next engery level so they will pass though the atom unchanged.
What is unclear to me is what you mean by being absorbed. As I say below, an electron cannot be absorbed, which is what I think you are implying above, but a photon, as the force carrier between electrons, can be absorbed and emitted.
I think there are duplicates for the other related questions in your post, so I will stick to the last two in this answer.
Why is it that the electron loses energy when it jumps to the next energy level
Let's take the common usage of the word jump as upwards. So in this above case, the electron gains energy. It loses energy when it falls back down to a lower level.
I have to admit that I don't like using words like jump and fall, because they are based on the Bohr model of the atom, which is not correct in almost every aspect.
So let me give you two pictures, one of the old model, which your question is based on, and one of the more modern picture.
The Bohr model (of 100 years ago)
The Orbital Distribution Density model
The electron will tend to lose energy if it can, by emitting a photon of the correct wavelength, that enables it to transition to a lower energy level, but if that lower level is already occupied to the maximum amount, then the electron is forced to stay at a higher level.
The difference between the pictures is the the Bohr model assumes a particle structure, whereas we now think in terms of the probability of finding an electron in a certain region, so we cannot be as definite as in the earlier model. Also, when the transition from one level to another occurs, it is not a smooth transfer like a car changing lanes, it is for a time a more chaotic operation, with the electron (or rather its' likelyhood of being found) bouncing around the place until it settles into a lower orbit.
In the first example the electrons moving with current gives energy to the electron in the atom. So the electron in the atom absorbs the moving electron? If so how is this possible because they are both negative?
There is no question of an electron absorbing another electron. Instead, by means of photon emission, momentum can be transferred between electrons, bearing in mind the conservation laws regarding energy and momentum.
An example of this is a Feynman Diagram:
Where the wavy line represents energy and momentum being transferred by means of a photon.
Best Answer
The key point missing from most efforts to answer this question are that the Sun has a temperature gradient with depth. If it were (somehow) isothermal, then indeed the absorption and emission processes would cancel and the Sun's spectrum would be a smooth blackbody.
The photons we see from the Sun, were those that were able to escape from its photosphere - an outer layer only a few hundred km in thickness.
The interior of the Sun is hotter than layers further out and the radiation field approximates to a blackbody, with a radiation flux that is strongly temperature dependent. The strong temperature dependence, combined with the negative temperature gradient means that the solar spectrum is produced by the hottest layers we can see.
Why the emphasis? Well, the depth we can see into the Sun is wavelength dependent. Where there are strong radiative transition probabilities, the light coming from the interior is absorbed. The re-emitted light (it has to be re-emitted if the material is in thermal equilibrium) is emitted in a random direction and a negligible fraction comes towards us.
I think there are two key points. One is the random direction of the re-emission of absorbed energy, but the other is the temperature gradient which means there is a clear outward directionality to the net radiative flux which means you can treat the Sun as a succession of cooler "slabs" as one moves outward.
The net effects are absorption lines. A good way to think about the solar spectrum is that at each wavelength you are seeing a (roughly) blackbody spectrum emitted at the temperature of the layer from which photons at that wavelength can escape. Thus the bottom of an absorption line is emitted at cooler temperatures, closer to the "surface", whilst continuum comes from hotter, deeper layers, but at wavelengths where the opacity is lower so that the photons are still able to make it out.