How was oxygen and nitrogen created?
Oxygen and nitrogen are created through nuclear fusion inside stars. All stars start out fusing hydrogen into helium. Then, if a star has enough mass, helium is fused into heavier elements, including oxygen and nitrogen. In the most massive stars, all the elements up to iron are created. When a star explodes as a supernova, the extreme temperatures and pressure fuse those elements into even heavier ones, like Uranium.