Our sun is about 4.5 billion years old and will live for another 5. The universe is about 13.5 billion years old. That means our sun was born when the universe was about 9 billion years old.
The heavy elements are formed when stars go supernova. We have lots of these heavy elements in our solar system, which means there must have been lots of prior supernovas to create it all.
But how can there be so many prior supernovas to make the material, blast it to space, and the material eventually coalesces into other stars and planets? Our sun is going to burn for about 9 billion years. How did all those other supernovas happen so much quicker? It doesn’t seem like the universe has been around long enough to create all this dust which eventually became our solar system.
Our Sun will also never go supernova. Supernovas are the fate of high-mass stars, and the more massive a star, the shorter its life. The most massive stars can have lifespans of a million years or less, which is a blink of the eye compared to the age of the Universe at the time of the Sun’s formation. The lowest-mass stars, meanwhile, are expected to be able to last for trillions of years.
Our sun is a medium sized star and has a medium long lifetime. Larger stars (somewhat paradoxically) have shorter lifetimes. Giant stars have markedly shorter lifetimes. (Technically the sun is a dwarf star, but there are no medium stars, just giants and dwarfs and a few other things.) The most massive stars have lifetimes of only (as I recall) a few million years, so there was plenty of time for many generations of giants to produce heavy elements found in the sun.
Stars have enormously variable life spans - small stars last tens of billions of years, but big stars might last only millions of years (or even less than a million years).
Our sun will never go nova or supernova because it doesn’t have enough mass. If a star has a larger mass, it has more intense gravity, which means the fusion reactions that turn hydrogen into helium and other elements happen more quickly, which means the star burns up much more quickly.
Our sun is billions of years old, but other stars are much younger. If those stars are more massive than the sun they will burn out faster, or if less massive they will last longer. Red dwarfs will last much longer than the sun. Hotter stars will burn out much sooner.
Supernovae aren’t some theoretical event which we think will happen to stars in the future, they are actually observed events that we’ve had to come up with an explanation for. A “nova” is a new star, a phenomenon well known to ancient astronomers. Sometimes a new star would just appear in the sky, sometimes bright enough to be seen during the day. Then the new star would fade away and disappear.
A star’s lifetime is a function of its mass. The lifetime of a star scales as one over the mass to the 2.5 power.
Two kinds of stars can go supernova. One kind of star that can go supernova is stars at least 8 times as massive as the sun. They don’t live as long as our sun does. Some of those stars only live about 10 million years.
In addition to what’s been said about about more massive stars having longer lifetimes, it’s also important to note that the first generation of stars in the Universe (so-called “Population III” stars) were considerably more massive on average than stars today. The basic idea is that a cloud of gas alone can’t cool off as quickly as a cloud of dust and gas; so the proto-stars formed out of hotter clumps of gas, and a hotter clump of gas needs to be bigger to collapse under its own gravity. (Otherwise, the pressure due to the increase temperature can “prop it up” against its own gravity.)
The net result is that your average Population III star is suspected to have been on the order of 100 times more massive than the Sun, and so would have burned out 100,000 times faster than the Sun — less than a million years.