Hydrogen and Oxygen by themselves have 1 and 6 valence electrons, respectively. 8 valence electrons is stable, so the atoms form bonds with each other to achieve 8 valence e-.
1 H atom + 1 H atom + 1 O atom = 8 valence e-
Is this a question or a statement?
pure substances can be divided into two groups; elements and compounds