It doesn't. The naive count of three degrees of freedom per nucleus is not wrong, but they are not all vibrational. In particular, you need to factor out
- three degrees of freedom for the translation of the center of mass, and
- three degrees of freedom for a global rotation, corresponding to the three Euler angles needed to specify an orientation.
This leaves three vibrational degrees of freedom: two internuclear distances between the oxygen and the hydrogens, and the bond angle at the oxygen. It should be clear that these are sufficient to specify a shape for the molecule and that they are independent.
It's also worth mentioning, by the way, that those degrees of freedom are not the most useful way to describe the vibrations, because it's essentially impossible for one internuclear distance to vibrate without affecting the other bond. Instead, you normally rewrite the dynamics in terms of three normal modes, which are able to vibrate on their own without affecting the others: thus, the coordinates of interest are in essence
- the sum of the O-H internuclear distances, corresponding to a symmetric stretch;
- the difference of the O-H internuclear distances, corresponding to an antisymmetric stretch; and
- the bond angle at the oxygen, corresponding to a bending mode of the molecule.
For more on the normal-mode description, see e.g. here.
If you have a diatomic, on the other hand, the calculus is similar, but slightly altered. You now have six global degrees of freedom and you take away three for the position of the center of mass, giving you three internal degrees of freedom. Now, here's the rub: for a diatomic you only need two Euler angles to specify the direction of the internuclear axis, since rotations about that axis don't change anything. This then leaves you one vibrational degree of freedom, which neatly corresponds to the internuclear distance.