Stellar evolution is the process by which stars change over time. The lifetime of a star depends closely on its mass. More massive stars tend to go through the different phases of stellar evolution much faster than less massive stars.
Stars are typically formed from gas clouds. Gravity tends to agglomerate the gas until a protostar is formed. After that, the gravity makes the protostar contract and, when pressure reaches a large enough value at the centre of the star, nuclear fusion of hydrogen may start.
Once nuclear fusion is activated, the star will reach an equilibrium state where the gravity and the pressure are compensating each other. This is called the hydrostatic equilibrium.
In the next steps of the life of the star, once the hydrogen at the center has been mostly fused into helium, the star will start to fuse helium and this will cause the star to gradually grow in size passing through the subgiant stage.
In the final stages of the star’s life, it will reach the red giant stage which is the last step of the evolution of a massive star and is characterized by a large increase in radius and a decrease in temperature!