IIRC, spy's don't receive that protection.
maybe they had their reasons for doing it, likely they had some sort of reason.
most criminals have a reason why they broke the law too.
obviously there can be certain advantages to keeping someones capture secret, and likely these types of advantages where know at the time these laws were made.
laws are made to clarify your acceptable course of action, and establish lits as to what is acceptable and how far you are allowed to go in an effort to accomplish your goals.
yes, war is an extreme situation which often requires extreme action.
but since these laws are directly concerning which actions are legal or forbidden in times of war, it's reasonable to assume that you would be expected to obey them even if you were at war.
a law that you ignore when it becomes inconvenient isn't a law, it's a guideline or a suggestion.