Transition metals show variable oxidation states because electrons from both the (n−1)d and ns subshells, which are close in energy, can take part in bonding.
Iron, [Ar]3d64s2, forms both ferrous (Fe2+) and ferric (Fe3+) compounds, such as FeSO4 and FeCl3.
Sodium and lithium in group 1 show only +1, and calcium in group 2 shows only +2, because removing a further electron from the noble-gas core costs too much energy.