How does sodium in water produce hydrogen and sodium hydroxide?
Sodium is more electropositive than hydrogen, so the oxygen, a highly electronegative element, will want to bond with the more electropositive element, sodium. There is already some a concentration of some 10^-7 moles per liter of ionized water, with the H+ separate from the OH- ions. The OH- anions of course are much more electronegative than the H+ cations, so the electropositive Na+ will react with the OH-, creating NaOH. Leftover H+ ions bond with each other to form H2 gas. Simultaneously, the Na+ will want to react with the oxygen, but only one thing can happen at once, so once one hydrogen atom has detached from the OH in a water molecule, the OH is electronegative enough to react with the sodium. NaOH is more stable than Na2O, so NaOH is formed rather than Na2O.