How is the Sun stable?
The thermal pressure from nuclear “burning” counteracts the gravitational pressure. An equilibrium exists: when a star like the Sun contracts, it heats up, as gravitational potential energy is converted to thermal energy. But fusion rate is very sensitive to temperature, and a small increase in temperature increases the fusion rate a lot. When the fusion rate increases, the star expands. When it expands, it cools. The fusion rate decreases, and the star goes back to its original size. These effects combine to give the star a very stable equilibrium point: any small departure from this equilibrium leads to a change which brings it back to the original state.