Where did ice/water on comets and planets come from? Supposedly solar system was formed from remains of a supernova, was the water somehow synthesied inside the star? Or what.
Oxygen (O) is created in stars. Just think of stars as "element factories", where Hydrogen (H) and Helium (He) are fused into heavier elements like ... well, like every other element than H and He.
The heaviest elements that Mankind hasn't recently created (like element 110) can only be created from supernovae. Normal stellar processes within operating stars pretty much max out at the element Iron (Fe).
Once you get all those elements mixing up in stellar clouds from all those supernovae, you end up with chemistry, resulting in H finding O and forming at least three structures that I know about: HO- radicals, H2O stable molecules (water), and H3O unstable molecules (ozone).