What occurs when a magnesium atom becomes a magnesium ion?