What happened is we had wars in Korea and Vietnam. In order to keep our supply lines short, we had spare parts and other gear built in Japan. That was a lot of our government money going to build up Japan's manufacturing. After a while, Japan was kicking our ass - they were buying movie studios and skyscrapers, here in the USA, in the 1980s, and their corporations dwarfed our largest.
What also happened is we have been generous in rebuilding Japan's and Germany's (among others, see Marshall Act) factories. They were newer than ours, more modern. At our expense.
We're also generous in how we give away money to other countries. $billions to Egypt and Israel, yearly. Foreign aid of all kinds to assorted countries. Money that could build infrastructure here but isn't.
We also made China MFN and shipped our manufacturing to their slave wage sweat shops. Our trade deficit with China alone is near $500B, if not more.
Other countries dump product in ours. We used to make steal. Then we were shipping our junk metal to Japan where they recycled it all and sold it back to us.
Other countries apply other unfair trade practices. Our private companies like Boeing are hurt by European governments subsidizing AirBus, for example.
We also made a number of trade deals that seem to have hurt. Our companies move manufacturing to Mexico because we incentivize them to do so. If you actually listen to Trump, he says those deals are bad and that we got a much worse deal than our partners. I think there's some merit to that, but I also think there's reasons it is OK to be helping other nations.
Our government cannot control its spending. In order to pay for what it cannot afford, the government borrows money from China (and other countries). We spend it on food stamps, which literally turns to shit. They end up holding bonds that the US pays interest on, and pays back the principal, too. We're taxing ourselves and sending $400B+ in interest payments to the Chinese.