It depends on how big the black hole is! If you’re dealing with a small black hole, then we have a pretty good understanding of how the black hole forms. The smallest astrophysical black holes are objects that form during the catastrophic explosions of dying, large stars.
These stars contain so much mass that when they begin to explode in a supernova, the shock wave of the explosion can ricochet down into the core of the star, compressing it down to the point that the object in the center of the star becomes too dense for electrons to hold atoms apart (the end point for a white dwarf), further down until the star becomes too dense for neutrons to hold each other apart (the end point for a neutron star) and after that point, the object becomes so dense that even light can’t escape it. At that point, it seems logical to assume that the object itself will continue to press itself inwards, subject to its own ever-increasing gravity, until it takes up no more space than an infinitely tiny point - a singularity.
Left behind, far outwards, is the contour in space which marks the threshold of no return for light - if light travels closer than this horizon, it’s not coming back. This spherical contour surrounding the black hole is known as the event horizon, and often this whole region of space is called the black hole, as it’s a region where the existence of the black hole is the most important thing around.
The black holes formed this way are a few times larger than our own Sun, made out of stars at least eight times larger than our own Sun. When you want to create black holes which are larger than that, like the supermassive black holes at the centers of galaxies, the situation has to be slightly different. These black holes are many, many times larger than our own Sun - millions to billions of times more massive than the black holes which form from individual stars. How did they form? If we want black holes to grow to this size, we’re going to have to give them a lot of time.
Fundamentally, though, we still need to take a lot of mass, and compress it somehow down to a sufficiently high density that it will continue to collapse down into a black hole. This is a tricky thing to do, because matter tends to resist collapse, so you need to have quite a bit of force involved. There are a few possibilities, though. One is to scale up the mechanism that we know works for smaller black holes, and start with a larger star.
On the scale of a supermassive black hole, this pathway is still starting pretty small. We even have the advantage of starting with the stars in the very earliest Universe, which are thought to likely be hundreds of times more massive than the stars we see near us now. When those larger stars explode, they should leave behind a black hole, which, while larger than the black holes we typically see from stellar explosions nowadays, would still need to grow considerably to reach the size of a supermassive black hole. You’d have to do some combination of feeding that black hole a lot of gas, or merging it with other black holes. But black holes are terrible at gathering gas efficiently into itself in order to grow in mass, and the mergers between black holes are also thought to take quite a long time, though they do happen if you leave them long enough.
Another option is to start large. How do you do that? Well, you could possibly build a tremendously large star, and let it collapse at the end of its life. This collapsing star would have to be tens of thousands times larger than our own Sun (and considerably larger than your standard early-universe star), but that would allow for a black hole many thousands of times more massive than our Sun to form when the star inevitably explodes at the end of its short lifetime. From that larger starting point, you would still need to grow a lot, over time, but if you start large you’d need less building. Going from 10,000 times larger than the Sun to the 1,000,000 times larger than the sun is much, much easier than going from 100 times larger than the Sun to 1,000,000 times larger than the Sun.
These large black holes are probably built through a combination of these possibilities, and potentially some other possibilities we haven’t yet constructed. These questions are part of why we built LIGO, and have plans to build an even more sensitive machine in LISA - those devices will allow us to figure out how common it is for black holes to merge together, and that can help us figure out what the population of black holes looks like in the first place. After all, LIGO has been full of surprises already!