The atoms bond because there is a strong enough attraction in both directions and room for the electrons in the outer energy level of the atoms. When two hydrogen atoms and an oxygen atom get close ...
The picture shows a close-up of one carbon atom. A hydrogen atom has one proton as the nucleus and one electron in the region outside the nucleus. The electron and proton are attracted to each other.