Magnesium forms a cation by losing its two valence electrons. Its electron configuration as Mg2+ is 1s² 2s² 2p⁶, which is the same as the electron configuration of the noble gas Neon (Ne).