The subatomic particle that gives off visible light is electrons
Magnesium element exists as single atoms. Free oxygen is always diatomic (two atoms bonded together) as O2. Nitrogen gas is also diatomic N2.
2Mg + O2 → MgO
Mg forms a +2 ion, O forms a -2 ion, so they combine and balance in a 1:1 ratio. MgO, magnesium oxide, is a solid.
3Mg + N2→Mg3N2
Mg forms a +2 ion, but N forms a -3 ion. Hence the Mg3N2 configuration for magnesium nitride.
Electrons move in what is called an electron cloud. Each atom has its own electron cloud associated with it. This region simply represents an area or likelihood within that an electron of corresponding energy can be found within.