Relative abundance of various elements following the Big Bang.
We just saw how most of the universe's hydrogen and helium (and trace amounts of lithium and beryllium) was synthesized after the Big Bang.
The atoms heavier than helium up to the iron and nickel atoms were made in the cores of stars (the process that creates iron also creates a smaller amount of nickel too). Stars around the mass of our Sun can synthesize helium, carbon, and oxygen.
Massive stars (M 8 solar masses) can synthesize helium, carbon, oxygen, neon, magnesium, silicon, sulfur, argon, calcium, titanium, chromium, and iron (and nickel).
But why were these four extremely light nuclei the only ones to form?
The answer is that fusion products involving 5 to 8 nucleons are very unstable, as shown in this animation with beryllium-8 (which falls apart almost immediately after it forms).
These reactions created the heavier elements from fusing together lighter elements in the central regions of the stars and through the explosion of white dwarfs or the merging of neutron stars.
When the processed material from these processes are thrown back into space, it can be incorporated into gas clouds that will later form stars and planets.
In the cores of stars, in supernova explosions, and merging neutron stars, new atoms are manufactured from nuclear fusion reactions.
You will find out where the hydrogen and most of the helium atoms came from in the cosmology chapter.