when sodium reacts with cold water, how can hydroxide and hydrogen gas both form?
Metals react with water and produce a metal oxide and hydrogen gas.
Metal + water → Metal oxide + hydrogen gas
However, if the metal oxide is soluble in water it further dissolves in water to form the corresponding metal hydroxide.
Metal oxide + water → Metal hydroxide
Hence for such metals, whose oxides are soluble in water, the overall reaction of the metal with water can be written as
Metal + water → Metal hydroxide + hydrogen gas
Sodium on reaction with water forms sodium oxide (along with hydrogen gas), which is quite soluble in water. This further dissolves in water to form sodium hydroxide, because of which the overall reaction of sodium with water is written as
2Na (s) + H2O (l) → 2NaOH (aq) + H2 (g)