There are 2 countries. One can only be productive and the other can wage war.
The other country will swallow the other one.
So, it’s toward the best interest of all country to improve their military spending rather than than making the pie bigger.
And that’s what most country do. And that’s how we got war.
In society, this is averted by government or majority of peaceful loving people. After all, if we’re busy killing each other, we won’t be able to kill others. In other places this is not the case.