Black holes form through various processes that involve the collapse of massive astronomical objects and the merging of smaller black holes. One primary method is the stellar collapse. Stars, during their lifecycle, fuse hydrogen into helium in their cores. When the hydrogen is depleted, they begin fusing heavier elements until iron is produced. For stars more than 20 times the mass of the Sun, the end of this fusion process leads to a supernova explosion. The core of the star collapses rapidly due to gravity, and if the core's mass is sufficiently large (typically more than about three times the mass of the Sun), it will continue collapsing into a singularity, forming a stellar-mass black hole.
Another way black holes can form is through accretion and growth. A compact object like a neutron star or a white dwarf can accumulate matter from a companion star or its surroundings. As this matter accumulates, the mass of the compact object increases, and it may eventually reach a critical mass where it collapses into a black hole.