It was a lot more insane in WW1, before we had these rules.
For example, they deployed gas that makes people vomit so soldiers can't keep masks on, followed by gas that dissolves the lungs so they suffocate on their own blood. Stuff that makes dying by conventional means merciful.
The Unmitigated Pedantry dude (shows up on this site a bit) makes a decent argument that chemical weapons mostly were abandoned because they don’t work against top-tier militaries, not really because we decided wars should be polite after WW1.
The defenders of a territory under attack aren't put in that position by any real choice of their own - none that is practical anyway. Being able to live with themselves after the conflict is over, being able to re-integrate them into civilized society, is an important facet of maintaining a peaceful society.
You don't plan for everything going well (no one ever goes for war). You plan for when things don't.
For example, they deployed gas that makes people vomit so soldiers can't keep masks on, followed by gas that dissolves the lungs so they suffocate on their own blood. Stuff that makes dying by conventional means merciful.