Check out this excellent animation from NASA which charts the life of a star from creation to white dwarf stage.
Stars are created when groups of space dust and gases, due to internal nebula turbulence, collapse under their own gravitational attraction. As the cloud collapses a dense, hot core is formed which continues to collect dust and gas before turning into the heart of a protostar. Over millions of years this star continues to gather material and mass before entering its main sequencing stage where it fuels its expansion by the nuclear fusion of hydrogen into helium deep within its core. This is the main stage of any star (the stage our sun is presently in) and is when the star is most stable, slowly and maturely fusing hydrogen into helium while transferring heat outwards via radiation.
After billions of years hydrogen reserves within the core run-out, severely slowing fusion and causing a massive reduction in energy. This lack of energy stops the sun from pushing its multiple layers outwards and, under the force of gravity, slowly starts to collapse in upon itself. Under this increased pressure the central temperature of the star rises to a critical point where helium, stored internally from the hydrogen fusion, starts to fuse together in the core, creating carbon and oxygen. Due to this vastly increased core temperature the force of expelled radiation becomes so great that it forces the star’s photosphere outward by a colossal distance, turning it into a red giant, and then due to the now weak gravitational pull on the outer layers, causes colossal mass loss to stellar winds.
Finally, after the star has exhausted its helium supplies and lost its outer layers, it enters the white dwarf stage of its life. With no fuel left to burn in its core and the pressure of outbound radiation reducing, the star is compressed by gravity continuously, becoming denser and denser to the point where its very electrons become smashed together. Finally, the compression of these electrons cause every energy level available within the individual atoms to be filled and are left with nowhere else to go, stabilising the newly formed white dwarf.