For molecules and polyatomic ions, the coordination number of an atom is determined by simply counting the other atoms to which it is bonded (by either single or multiple bonds).
In H2O , the atom O is bonded to two H atoms through covalent bond and is bonded to two other hydrogen atoms through H-bpnds. Thus, there are total of four hydrogen atoms close to oxygen atoms.. Therefore, the coordination number of O in H2O is 4.