Although the US isn't a member of one of the various large port state organisations it is enormous, and it has a lot of coast, so the US Coast Guard effectively acts as a Port State Control authority the way that say the Paris MOU or Tokyo MOU do, but with potentially less friction because instead of Spain and Germany or Japan and Australia having to agree what happens it's just Florida and New York, which are ultimately both responsible to the US Federal government.
If you have a Port State Control regime then the Flag State Control doesn't matter so much and so while it's true that most of these ships do not fly a US flag, they're not really sailing under a foreign flag for the reason you expect. A big reason instead is that these states have an Open Registry, which means everybody in the world can put a ship on their register. To fly the US flag, the ship's owners must be Americans.
Why doesn't Flag State matter so much (if you have PSC) ? Because the port states in effect control regulations if you visit their port, and unless your vessel somehow makes sense just pootling around in the ocean forever you will want to visit a port and thus be subject to their rules. Now, if that port doesn't have Port State Control, which fifty years ago none of them did, the Flag State is the only authority, but in 1978 the Europeans are agreeing rules to protect workers on ships in their water when blam - a shipping accident off the French coast causes world headlines. So of course journalists want to know, you're agreeing a treaty, how will your treaty fix this? And the bald answer for the intended treaty text was "It makes no difference, fuck off". But there are international journalists up in your grill and you've been telling everybody how important your treaty is and so... Port State Control, the Paris MOU is signed a few years later to formalize how Europe's states will coordinate to police everybody, regardless of the flag they're flying, if they enter a port.
The Paris MOU was a huge success, and soon anywhere with money imitated it. Tokyo MOU, there's a Carribean one, Indian Ocean, Black Sea... Anywhere you'd actually deliberately sail cargo ships to has Port State Control these days.
So yes, this does exclude all the cargo shipping, but not really because of the flag, it's because the cargo ships are enormous and so fall out of the size restriction.