Before the first stars formed, the universe contained only HYDROGEN, HELIUM, and small amounts of LITHIUM (created in the first minutes after the Big Bang, when the universe as a whole was still hot enough to sustain fusion).
But massive stars create carbon, oxygen, and all manner of heavier elements through fusion all the way up to iron.
When these stars run out of fuel and explode as supernovae, the huge amounts of energy released often allow for the formation of even heavier elements like gold, uranium, and others.