Assuming the mass of the material is large enough, gravitational compression reduces the size of the core, increasing its temperature until hydrogen fusion can begin.
This hydrogen-to-helium fusion reaction releases energy that balances the inward gravitational pressure and the star becomes stable for millions of years.
No further gravitational compression occurs until the hydrogen is nearly used up, reducing the thermal pressure of the fusion reaction.
For planets and moons, equilibrium is reached when the gravitational compression is balanced by a pressure gradient.
This pressure gradient is in the opposite direction due to the strength of the material, at which point gravitational compression ceases.