Two hydrogen atoms share their electron with one oxygen atom creating covalent bonds, the shared electrons are pulled towards the oxygen atom due to the two lone pairs of electrons it has,
giving the oxygen atom a partial negative charge and the hydrogen atoms a partial positive charge resulting in a polar molecule due to the unequal sharing of electrons.
These partial charges then attract other water molecules allowing hydrogen bonds to form between the opposite partially charged atoms