I agree with the sodium equation, I disagree with the Magnesium reaction.
Magnesium reacts with water to form hydrogen gas and magnesium hydroxide.
Mg (s) + 2 H2O (l) → Mg(OH)2 (s) + H2 (g)
Was your source of those equations a person, book, or other internet place?