Bankruptcy carries a lot of side-effects though, like losing access to any credit for a period of years (laws differ from country to country, but that’s one of the most common outcomes).
Not any credit, just credit on the best terms. Credit card companies are perfectly willing to lend relatively small amounts of money on their more profitable cards to people with recent bankruptcies. Yes, they have poor money management skills or other issues. But they cannot declare bankruptcy again and have had their debt obligations reduced to a reasonable level, which dramatically improves their credit risk.