This is such a good question that the answer is not particularly settled yet - we have some ideas for how some supermassive black holes may have gotten so large, but it’s not clear that the explanations we’ve come up with so far hold true for all supermassive black holes.
So a few definitions before we launch into our ideas - by and large, all massive galaxies have a gigantic black hole at their centers. To distinguish these central black holes from the type of black hole created when a single, massive star ends its life, we named the big ones “supermassive”. The black holes created from single stars are less entertainingly named “stellar-mass black holes”.
Black holes of all sizes are extremely inefficient at gathering new material to themselves. Rather than absorbing nearby material in one fell swoop, the material is more often than not pulled into a tight disk of extremely hot material, or flung away from the black hole entirely, sometimes at relativistic speeds. For all black holes have a reputation of being cosmic garbage disposals, if you had a garbage disposal this terrible in your own kitchen, after the first time it blasted superheated onion bits on your ceiling you’d call a professional to have it removed ASAP.
So it is an eminently reasonable question - how do you make a black hole that’s thousands of times larger than the ones that are made by stars, when they’re exceptionally bad at growth? This question is made more complicated because right now, getting a star to explode in a supernova, and the remnant collapsing down into a black hole is the most robust theoretical model we have to make a black hole, so you have to somehow bridge the gap between something that contains a few times the mass of the Sun and something that contains thousands of times the mass of the Sun, while that thing steadfastly refuses to grow rapidly by accreting new material onto itself.
What can we do? Well, we can either 1) start larger, or 2) grow differently. If you start larger, then you have the benefit of not having to grow by a factor of several thousand but only by a couple. This method means you have to start with “seed black holes” very early in the universe. You can do this in one of two ways. First is the direct collapse model - the thinking goes that it might have been possible, very early in the universe for enough gas to collect together that its gravity would just collapse all the way down to a black hole, skipping the star phase entirely. The second method is effectively to go through a star first, but to go through a very, very large star - something much larger than the Universe makes nowadays, which would burn through its hydrogen much faster, and would make a larger black hole as a remnant.
What about growing differently? It’s possible that instead of growing by slurping tiny fractions of gas and dust from its surroundings, the black holes grow by absorbing other black holes. This raises a whole string of other questions, like “are there even enough black holes around for that to work?”. We know that there should be times when galaxies gain a second supermassive black hole - during galaxy collisions. The remnant of the two galaxies should have two black holes which sink together, immediately doubling their mass. But it’s unclear if you can guarantee that enough galaxies will smash together enough times for this to work for all the galaxies we see, especially since not all galaxies are expected to merge with another galaxy the same number of times.
There’s no reason the answer will wind up being one or the other - some combination is likely to be in play. If you can start with a larger seed in the early Universe, you can grow more easily through a combination of colliding with the supermassive black holes in other galaxies, and by gathering gas inefficiently to themselves.