Isn't the traditional response to post a few blokes with guns, big guns, and attempt to blow any pirates out of the water? Aren't ship's crew using guns for protection?
We wouldn't let a <pick a foreign country not too friendly with us> warship steam into Boston Harbor. Same country's oil tanker or cargo ship? Come on in.
Presumably US flagged vessels are armed?
Naturally, US military vessels, including the Coast Guard, are armed.
Nothing prevents a shipping company from saying "In order to take a job on my private ship, you are barred from bringing weapons on-board."
Nothing prevents a country from saying "If your merchant vessel desires access to our ports, it shall not be armed."
The combination of those two (effects, not necessarily codified policies or laws) means that merchant vessels aren't armed.