"I was just following orders" was not a valid excuse for the Nazis, and it isn't a valid excuse for our own men.
The reason it's not accepted is because it's too difficult to discern if it's a lie in order to (attempt to) avoid punishment.
Following an order to attack an enemy in time of war, when you'll probably die for not attacking them ... if you knew for certain the enemy wasn't trying to trick you, and were genuinely saving civilians, then of course you should disobey, ... maybe ...
Even if that particular captain was saving civilians, it may still ultimately save lives to sink the enemy ship; that's the "glory" of war. Taking a pragmatic approach then, sinkng the ship can be considered "moral".
Indeed taking such an a priori callous action could require a degree of bravery.