Final answer:
Hydrogen atoms are created through nuclear fusion in stars, while oxygen atoms are formed in the cores of massive stars through nuclear fusion reactions involving helium and carbon. When these stars explode, they release oxygen and other elements into space, which can then form new celestial bodies like Earth.
Step-by-step explanation:
Hydrogen atoms are created through nuclear fusion in stars, where four hydrogen nuclei combine to form one helium nucleus, releasing a tremendous amount of energy in the process. These helium nuclei can later undergo further fusion reactions to form heavier elements. As for oxygen atoms, they are created in the cores of massive stars through nuclear fusion reactions involving helium and carbon. When these stars eventually explode in supernovae, they release oxygen and other elements into space, which can then go on to form new celestial bodies like Earth.