I *love* this question leanneypan – what a great piece of thinking!
Oxygen and hydrogen are both gases (at ‘room temperature’ – about 20°C) because the molecules don’t interact very strongly with one another (even if you mix the 2 gases).
But when they combine chemically to make H2O, everything changes because of the formation of the bonds between the atoms.
In the molecule, the O has a slight negative charge and the H has a slight positive charge (due to rearrangement of the electrons between the atoms). As a result, water molecules stick to one another much more tightly. Tightly enough so that H20 is a liquid at room temperature.
I don’t think it is unusual in chemistry for compounds to behave very differently from their constituent elements. Salt for example is made up of sodium and chlorine, but its properties are very different from either element.
I am not sure about this, but I think one of the reasons water is liquid at room temperature is that each molecule can form very weak “hydrogen bonds” with it’s neighbours. This restricts the amount the molecules can move around, keeping water liquid over a range of temperatures, whereas e.g., carbon dioxide does not have a liquid phase.