Ships in international waters should be able to protect themselves. Pirates are often heavily armed, and they are not afraid to take hostages and use deadly force. It is dangerous for the crew and for investors in shipping companies not to defend themselves. Pirates will stop attacking ships if they know that they are armed.
Yes, shipping vessels should stockpile weapons to combat piracy, because in reality, each ship is its own best method of defense. Responding to piracy is more or less the ship's own job. It would take a lot of time for someone else to arrive to help. The ship should do everything it has to in order to protect itself.