Nearly all ships are registered to a country. By registering with a country you agree that the laws of that country apply. Those laws can include anything they country wants - including speed limits enforced by whatever means. In return the Navy of that country (and applied Navies of other countries) will help defend you from pirates and other military action.
There is such as thing as unregistered ships. They are called almost always pirates up to no good: most navys will sink them on sight. Most ports will not allow an unregistered ship.
The Paris MOU and Port State Inspection changed the status quo here forever.
If an Open Registry (the technical name for a "Flag of Convenience") doesn't enforce rules the Port States (mostly economically important countries with a coastline) care about that flag essentially labels you as likely non-compliant - and whether you are or not it's a world of pain because those Port States care.
So most of the famous Flags of Convenience cleaned their acts up. It just made too much financial sense.
You can try mumbling about how Port State Control isn't fair, but the people who think it is have guns and money and you don't. In this case (and many previously) this works in our favour.
Panama at least has close ties to the US. If they want to enforce laws they can call the US and get a large fleet to help. Panama also has the canal which is important to global shipping: if they want to they can refuse ships passage if they don't comply with whatever rules they want.
Of course the IF above is big. I don't know how to get Panama to care.
There is such as thing as unregistered ships. They are called almost always pirates up to no good: most navys will sink them on sight. Most ports will not allow an unregistered ship.