of course it came from the combining of oxygen with hydrogen. It is not as though water stays as water forever either. Most of the water that is on earth apparently originally formed in the solar nebula from which this solar system formed.
Water is what you get when the oxidation state of the system (the sum totality of all elements and their strength in competing for electrons, in effect) is in a window that is not too oxidizing (not too filled with electron-grabbing elements like oxygen and halogens) and not too reducing (not too filled with elements that have a weak hold on electrons such as alkalis and metals), but only in the middle zone.
Where this window lies does vary with temperature and pressure, but it always exists.
Water does not form and then stay as water, with the same one oxygen atom and two hydrogen atoms, forever. It is always interacting with other materials int he system, whether CO2 or other acid-forming compounds, or with metal and alkali salts in the earth (silicate minerals are "salts" in this sense; silicates are a conjugate base of a weak acid) .
The bulk of the earth system (until you get down to the core) is located within that water stability window. Water is to be expected as a stable compound in most of the earth system. You do not need an exotic source of water. Water will form if there is hydrogen and oxygen around. Methane plus a silicate mineral will react and produce some water and a different (less oxygen-bearing) silicate mineral, for example.
No compound is permanent in the way you want to think about it. Everything has an average lifespan of sorts, an average period of duration. When chemical compounds move around, they interact with the new stuff they encounter. They exchange components.
This can be easily proven by use of stable isotopes as tracers, as one method. When water interacts with rock, the isotopic composition of both the rock and the water changes. This means that the oxygens and the hydrogens are exchanging places. There is no "a water molecule passes around forever, unchanged". There are so many water molecules that the bulk existence of water seems as though it does not change, but it does in detail.
As to the water on earth, I am in the school of thought that it all comes from the initial accretion of nebular mass, along with everything else. It eventually migrated to the surface, because it is a volatile compound, a compound that is liquid or gaseous at very low temperatures (relatively speaking). Some people believe that the oceans came from the "late" arrival of water-rich comets.
When you have a hydrogen-dominated gas giant, that hydrogen likely would make water if only someone would introduce some oxygen-containing compounds to the system. Oxygen-containing compounds and free hydrogen as H2 are not, generally speaking, compatible. They will react. The same is true in the other way: hydrogen containing compounds are generally not stable in the presence of free oxygen (O2) and will react.
Water tends to be the product in either situation.