1) There were two main phases of element formation in the universe: primordial nucleosynthesis during the Big Bang formed light elements like hydrogen, helium, lithium and beryllium. Stellar nucleosynthesis inside stars formed heavier elements through nuclear fusion.
2) During stellar nucleosynthesis, the high densities and temperatures inside stars allowed for nuclear fusion reactions to form heavier elements up to iron. Elements heavier than iron could only form during supernovae explosions.
3) Supernovae explosions were massive stellar explosions that created conditions for neutron capture reactions to occur, synthesizing elements heavier than iron.