1. by owning the (often insane) debt from the programs
2. by getting a lot of Chinese jobs in the country
3. by gaining influence over the country (at the expense of Western influence, if you see this as a competition.
Another problem here, although it’s not a benefit to China, is that the quality of infrastructure built by China is often terrible, making the cost and debt even more problematic.
Now, having said all that, the US isn’t necessarily doing much better. And the poor quality Chinese roads (just as an example) are still infinitely better than the competing local-built roads.