Here's why:
* Red Giant Phase: Red giants are stars in their later stages of life. They've exhausted the hydrogen fuel in their core and are now fusing heavier elements like helium. This fusion process causes the star to swell significantly.
* Outer Layer Loss: As the core continues to fuse heavier elements, it becomes unstable. Eventually, the outer layers of the star are ejected into space, forming a planetary nebula.
* Core Collapse: The remaining core, now incredibly dense, collapses under its own gravity. It shrinks dramatically to about the size of the Earth.
* White Dwarf Formation: The collapsed core, composed mostly of carbon and oxygen, is called a white dwarf. It no longer generates energy through fusion and slowly cools over billions of years, eventually becoming a black dwarf.
Let me know if you have more questions!