Stars are fueled by fusion energy, the energy created by smashing together atoms into bigger atoms. The force of gravity acts on a star, pushing inward toward collapse, but the star doesn't collapse because the energy from fusion balances out the gravitational force. A star begins with hydrogen, which it smashes together to form helium. If stars are big enough, when their hydrogen supply runs out, they begin smashing helium atoms together and continue this process to make bigger and bigger elements. If the star gets all the way to iron, the balance between fusion and gravity is broken, because the fusion of iron does not release enough force to counteract the gravity. The outer layers of the star collapse and then explode outward in a huge supernova explosion. The remaining inner part of the star, if big enough (about triple the mass of our sun based on Einstein's predictions), will be collapsed inward by the force of gravity. The entire mass is collapsed into a single point by the immense gravity, forming an infinitely dense black hole. If a black hole is in empty space it will remain relatively dormant. However, if there is gas or dust close enough, it will be drawn into the black hole in a process known as accretion. The particles will be pulled in by the black hole's gravity, circling around it and releasing light as they speed up until eventually they enter the black hole and add to its mass. If two black holes draw near each other, their gravity will attract and they will merge together. The immense mass involved in this process releases huge disruptions in spacetime known as gravity waves. Black holes can grow by both accretion and mergers.
Although it is the leading theory, the stellar collapse theory of black hole formation has some flaws. Firstly, at the center of most galaxies, there are supermassive black holes billions of times more massive than our sun. For these black holes to have started out as collapsed stars and grown to the size that they are, it would take longer than the Universe's age to accumulate that much mass. Secondly, based on the stellar collapse model black holes would exist in all masses corresponding to stars. However, only supermassive or relatively small black holes have been observed, no intermediate size ones. With supermassive black holes taking an impossibly long time to grow to size, and no detection of the logical intermediate-mass black holes, it is clear that there is much that is misunderstood about black hole formation.
[P1] Gravity attempts to collapse stars inward. [P2] Fusion energy from the star balances out gravity, preventing collapse. [P3] When fusion energy is no longer sufficient, the star collapses. [P4] Massive enough stars collapse all their mass into a tiny point, creating a black hole.