International maritime law is strange and often counterintuitive. If those pirates boarded a commercial vessel and are dispatched by the crew of that vessel who have no authority to enforce laws and who can't prove beyond doubt they felt their lives were in immediate and real threat, that crew is guilty of murder. If they used weapons with capability to kill by design, that further incriminates them. This is why many vessels that sail dangerous waters have forms of non lethal force. The Somali pirates have means to counter those in their relative sophistication.
If a int'l recognized law enforcement is on board, that changes things, but the weaponry rules still exist. It is much weirder than even this. And.... few practice it anymore which means those who do have the upper hand when they bring suit against shipping companies. If these rules didn't exist, Somali pirates would be a joke and nowhere near a threat. Because they exist the pirates exist.