Wars then are prevented only by a balance of power and military deterrence: Aggressors have to be warned that it would be stupid to start a war they will likely lose. If there are miscalculations or if emotions run high and logic is ignored, then the resulting conflicts only end when one side loses and has no choice but to accept the imposed terms of the winner.
That being said, the modern therapeutic West has either forgotten such rules or ignored them. In today’s globally televised wars, a novel doctrine of proportionality reigns. It is sort of like T-ball, in which scoring and winning don’t matter. Instead both the stronger and weaker sides end up the same. Little attention is paid to who started the conflict, how it was conducted, or how it should be ended.
In terms of the Middle East, contemporary T-ball war works out like this: A far weaker Gaza sends a shower of missiles into Israel, hiding its launchers among civilians to ensure collateral damage and favorable propaganda during Israeli retaliation.
Israel, with its technological savvy, knocks down most of the incoming rockets, but then responds by killing far more Palestinians in Gaza than it lost inside Israel. That is considered unsportsmanlike play. In a fair T-ball fight, Israel should have stopped the war when the losses were equal and not tried to run up the score.