Red giants are evolved from main-sequence stars with masses in the range from about 0.3 to around 8. When a star begin to form from a collapsing molecular cloud, it contains primarily hydrogen, helium and trace amounts of "metals". These elements are all uniformly mixed throughout the star, which reaches the main sequence when the core reaches a temperature high enough to begin fusing hydrogen and starts hydrostatic equilibrium.
The star, over its life, slowly converts the hydrogen into helium; its main-sequence life ends when nearly all the hydrogen in the core has been fused. When the star exhausts the hydrogen, nuclear reactions can't continue and so the core begins to contract due to its own gravity. This brings more hydrogen into a zone where the temperature and pressure are adequate to cause fusion to resume in a shell around the core. The star's outer layers of the star expand, starting the star's red-giant phase.
As the star expands, the energy produced in the star's burning shell is spread over a much larger surface area, resulting in a lower surface temperature and a shift in the star's visible light output towards the red. A red giant emerges.