China isn’t doing this for the money. They do it to keep those countries under their thumb. It’s more like, “Yeah, you owe us a billion dollars, but we’ll forgive half of it and give you a fifty-year extension on the rest because we’re just the best of pals!” And then your country is expected to vote with China in the UN for the next three decades. On top of that, it makes the Chinese government seem really rich and powerful, which is helpful for both its internal and external politics.
China is trying to buy its way to the top like the US did in the mid-twentieth century.