How do the gasses and densities of a star change of its life time?
As stars get older they get denser and contain heavier elements.
When a star is born is is mainly hydrogen with smaller quantities of helium and heavier elements.
While a star is in its main sequence is is fusing hydrogen into helium. So, the amount of helium in the star increases and it gets a bit denser.
Once the hydrogen is consumed helium fusion starts. This produces carbon, nitrogen and oxygen. Again the star gets denser as the heavier elements replace the lighter elements.
Smaller stars don't get hot enough to start carbon fusion, so they end up as white dwarfs which are mainly carbon and oxygen.
Larger stars are hot enough to fuse carbon and heavier elements. They continue fusion reactions, getting increasingly denser, until the core is mainly iron and no further fusion reactions can take place as they require additional energy rather than releasing energy.
A typical iron core will collapse under gravity to form a neutron star. These are very dense. If the core is large enough the neutron star will collapse into a black hole.