Because technological progress was wars increasingly ugly, and winning today does not prevent you from losing the next war, so you could become a victim of the same war crimes you committed earlier.
And it wasn’t “everyone decided one day”. Different countries had different rules for themselves, and some signed Geneva conventions a lot later than others, and some did not follow them.
Here is the official history: https://en.wikipedia.org/wiki/Geneva_Conventions#History
Latest Answers