(a) With the exception of noble gases which have eight electrons in their valence shells (He has 2 electrons) and are in the minimum state of energy, all other elements have one to seven electrons in their valence shells. Thus, to attain a state in which they have minimum energy, they either lose or gain electrons, so that their valence shell has eight electrons. However, in doing so their positive and negative charges get unbalanced and hence they form charged ions.
(b) Metals form positively charged ions.
Na - e- → Na+
Mg - 2e- → Mg2+