Secondly, violating international waters legitimises attacks. It gives the attackers reason to say "they strayed into our territorial waters and opened fire on us" and legitimises the price tag they ask for ships and lives because essentially, the cargo vessel commuted an act of war.
Staying legally kosher when shooting up shit on the water is very fucking important.
If the attackers are saying the cargo vessels are straying into our territorial waters and opening fire when they attempt to board the vessel, then they're representatives of their government and committing an act of war by boarding a foreign nation's vessel and killing its crew, and we should treat this as an act of war and declare war on Somali.
If they are not representatives of their government, then Somali should be actively taking measures to eliminate piracy in their waters.
Since Somali is obviously not actively taking measures to eliminate piracy in their waters, the government is either in direct collusion with the pirates, and they are acting as privateers under tacit Somali authorization, or the government is incapable of enforcing their borders, thus not a legitimate nation, and we should have no need to comply with their borders in order to defend our ships.