“Unrestricted submarine warfare violated maritime law.”
So was a blockaid of neutral shipping. The Royal Navy forbade any neutral American ship from entering a German port.
But that is the story of WWI propaganda. Brits can do any violation they please. The Germans are wanton war criminals.
The difference is the British and other belligerents, both in the Entente and Central Powers never engaged in unrestricted, unprovoked attacks against neutral shipping. The Entente naval forces boarded and searched neutral ships and turned them away. The didn't just sneak up and pump a torpedo into them.
Germany's practice was wrong.