First, stars evolve at radically different rates. The higher the star's mass, the faster it evolves. The more massive stars had plenty of time to go through multiple generations before the Sun started to coalesce.
It went even faster than it does today, because the collapse of interstellar clouds to form stars is halted mainly by radiation pressure from the new star blowing the rest of its birth cloud away and ending accretion. Since hydrogen and helium are transparent to most of the new star's radiation, the very first stars could grow larger than stars do today. (They were pretty much made of nothing but H and He (with a bit of Li), since very little of the heavy elements had yet formed.) They went through their lifetimes and turned into supernovae and neutron stars very quickly. The largest had lifetimes on the order of just a million years.
So by a very short time after the first stars lit, they were already spewing heavy elements back into space and later stars already had some heavier elements in them at formation. The fraction of heavy elements has increased steadily since then, but the Sun formed many billions of years after heavy elements became common.