The gas ejected by supernova explosions contains the heavy elements cooked up in the the nuclear furnaces of the former stars. This "enriched" gas will mix in with other interstellar gas clouds, and when new stars are formed from these clouds, they will contain a higher proportion of the heavier atoms.
As our Milky Way galaxy ages, each new generation of stars contains more and more of the heavier elements.
The elemental abundances in the Sun are representative of mix found in stars being created now.
Elements heavier than iron (56Fe) are formed by neutron capture (during supernova explosions and in red giants).