Stars form inside nebulae made of hydrogen, helium, and dust. As gravity pulls material together, nuclear fusion ignites, and the star’s mass determines how it will evolve over millions or billions of years.
Low- and medium-mass stars expand into red giants and shed their outer layers, leaving behind white dwarfs. Extremely massive stars become red supergiants and end their lives in supernova explosions, ejecting material into space.
If the remaining core after a supernova exceeds about three times the Sun’s mass, gravity overwhelms all forces and collapses the core into a black hole.
Source: NASA – Stellar Evolution and Black Holes