How was water formed if oxygen and hydrogen exist as molecules?
Water does not have two oxygen atoms (has one) and one hydrogen (has two) hence the molecular formula of water is H2O. Water forms when there is enough energy to break the molecular bonds within the Hydrogen and Oxygen diatoms, they then combine and form water. As Mathew said, look at the Standard Gibbs free energy of formation. It will explain that H2O is much more favourable to be formed than H2O2.