You are neglecting two important facts.
The first one is that stars, toward the end of their lives, return to the interstellar medium (ISM) a lot of their initial mass, but now enriched with heavy elements produced by nuclear reactions inside the stars themselves.
In this way, younger stars which form from the ISM begin their life with a larger fraction of heavy elements than old stars, which formed earlier when the ISM was less enriched than it is today.
Most stars return a lot of material to the ISM, with the only exception of very low mass stars. This occurs in different ways, depending on the star mass.
Stars heavier than $8 M_\odot$ (that's eight times the Sun) first lose mass through powerful winds (in the most extreme cases, the so-called Mira variables, a heavy star can throw away 90% of its mass), then with SN explosions.
Stars lighter than $8 M_\odot$ do not experience SN explosions, and undergo lower rates of mass loss, but they still lose much mass.
Stars roughly the mass of the Sun also lose mass, in much less powerful winds or in the so-called Planetary Nebula phase, on their way to becoming a small white dwarf. The PN ejections are rich in CNO, as shown by the fantastic colors of their surroundings.
Lastly, stars considerably lighter than the Sun shed little or no mass.
Keep in mind that all of these episodes of mass loss occur when the star is old, i.e. when most material has gone through one stage of nuclear burning (H-> He) or maybe even more (He-> C,N,O, CNO-> Fe,Mn,Mg,...), so that the material returned to the gaseous phase (the ISM) is much richer in heavy elements than that from which the star formed.
There is a second fact to keep in mind. Since large stars burn nuclear fuel much faster than low-mass stars (there is an approximate law $L \propto M^4$ relating luminosity to star mass), large stars live very little, a few million years, while low-mass stars formed shortly after the big bang are still here. So, when you are talking about PopII stars, those are old: they formed a long time ago (from 12 to 7 billion years ago in our Galaxy); instead, PopI stars are either intermediate in age (like the Sun, 4.5 GYr old) to very young (even just 1 Million years ago!).
What this means is that, with PopII stars you are seeing stars that burn nuclear fuel very slowly, and formed when the ISM had not yet been enriched by the recycling of stellar material. With PopI stars you see instead stars which both formed recently, from an enriched ISM, and which bring to the surface the products of their own nuclear burning. Both effects make PopI stars much richer in heavy elements than PopII stars.