1) Elements lighter than iron, such as hydrogen, helium, and lithium, were formed in the early universe during the Big Bang via nuclear fusion of protons and neutrons (Big Bang nucleosynthesis).
2) Heavier elements up to iron are produced through nuclear fusion reactions in the cores of stars as they evolve on the main sequence and later stages. Fusion of lighter elements releases energy.
3) Elements heavier than iron are produced by neutron capture processes during supernova explosions, which blast material from the cores of massive stars into space, contributing to the chemical evolution of galaxies.