Answer:
Magnesium has an atomic number of 12 meaning it has a valence of 6, the high valence means it drops 2 electrons. Sulfur has an atomic number of 16 meaning it has a valence of 2, it takes on 2 electrons to fill that valence.
Step-by-step explanation:
Magnesium has an atomic number of 12 meaning it usually has 12 electrons and 12 protons. It has 3 orbitals with the third one only having two electrons. Since an element always want's a full orbital the magnesium gets rid of two of these electrons since it's closer to 10 than 18. So, it loses part of it's negative charge. This leaves it with 10 electrons and 12 protons since the first and second orbitals together need a total of 10 electrons to have a full valence. The third orbital is dropped altogether.
This results in magnesium often becoming 2+ ion as Mg^2+.
Sulfur has an atomic number of 16 (16 electrons and 16 protons) which is just two electrons short of filling the 3rd orbital (18 electrons). Since sulfur wants a full orbital and is close to completing it, it takes on two electrons to reach 18 electrons. Since there are now 18 electrons (negative charge of 18) and 16 protons (positive charge of 16) this results in a negative charge of two.
This is why sulfur forms a 2- ion as S^2-.