While there are many potential answers to how the universe itself was created, the answer to how water was created goes to that very question. The two elements that make up water are hydrogen and oxygen. Hydrogen is the most common element in the universe and is believed to be created at the very beginning when our universe came into being.
The most widely accepted, although still imperfect, scientific answer for the creation of the universe is the big bang. What exactly happened before and immediately following the creation of the universe is still unknown, and likely unknowable, but shortly after that point, fractions of a second, matter started to come into existence.
In its first widely recognizable form after the creation of the universe matter consisted largely of protons and electrons of such energy that they didn’t come together in any meaningful way. However, as the universe cooled, these protons and electrons combined to form hydrogen, which leads us to the first real step in the creation of water.
Over a much longer period of time than it took for hydrogen to form, clumps of that hydrogen started to condense out of the cloud that was the early universe. As these clumps grew larger they started attracting more and more hydrogen though gravitational attraction. As these clouds grew larger and larger they coalesced through the force of gravity into stars.
Gravity compresses stars to the point that it pushes the nuclei of atoms together to where they combine to create different elements. The primary reaction that powers stars pushes two hydrogen atoms together to create a helium atom. In the center of the stars, however, the forces are even greater. It is here where all of the larger elements that exist in the universe are formed.
The energy released by nuclear reactions is what makes stars hot. This energy, as it flows outward form the star also keeps the star from collapsing on itself due to gravity. Sometimes stars just use up their fuel and go out.
However, larger stars can die spectacularly. As the fuel that prevents the collapse of the star is used up and the star begins to implode, further reactions are caused along with the energy of the collapse itself. These reactions can become so violent that the star blows out in a supernova blasting all of its components out into the universe.
This is how the heavier elements that make up planets and the like come from, dying stars. The oxygen that makes up the second component of water was created in this manner.
The chemical nature of hydrogen and oxygen are such that, whenever they get in close enough proximity they will combine to create water. Water is a stable enough compound that it doesn’t easily break apart. Once water has formed in any quantity it will be around for a long time.