The number of protons is what defines the element. Oxygen, for example, has eight protons. However, the number of neutrons in an atom can vary, leading to different forms of elements, called isotopes.
When two hydrogen atoms and an oxygen atom get close enough, the electron from each atom feels an attraction from the protons in the other atom's nucleus. This attraction pulls the atoms together. The ...