Black holes form massive stars after they have 'burned' all of their 'fuel'. When stars are 'burning' (we call this special type of burning fusing) their nuclear 'fuel' (elements like hydrogen and helium), the star generates a lot of heat. Just like when a hot air balloon expands and rises as it is filled with very hot air inside, the hot gasses of the star are held up against the star's strong gravity. So, most of the time, the pressure of the gas is balanced by the star's strong gravity. When most of the fuel is gone, the hot gas begins to cool, and there is less pressure to hold it up against the star's gravity. When this happens, the gas begins to fall toward the center of the star. The star's volume (amount of space it occupies) gets smaller, even though it 'weighs' the same amount (contains the same amount of mass).
Now, how strong the gravity of a star is at its surface depends on how much mass the star has and its volume. For example, if two stars have the same amount of mass, but one is much smaller, the smaller one will have much stronger gravity at its surface. So, as the star cools, just like a deflating balloon, it gets smaller. The smaller it gets, the stronger its surface gravity gets, the smaller the star gets, and so on. If the star is big enough, about three times as massive as the Sun or more, this collapse will not stop, and the star will shrink to an infinitely small speck, with gravity so strong, even light light cannot escape - a black hole.