How can nations prepare for surprise events without being pushed into war?

and how do you avoid such awful conflict, make peace instead?
How can nations prepare for surprise events without being pushed into war?

https://www.independent.co.uk/news/uk/home-news/military-chief-threats-challenged-adversaries-b3073511.html

https://www.independent.co.uk/bulletin/news/army-chief-uk-roland-roly-walker-war-b3068389.html

We've seen this story in history as govts ramp up military to prepare for threats. But the casting of people into military and war is often some remarkable event... death of a statesman/politician, attack of an ally including forged and faked ones [North Vietnamese attack was false... starting Vietnam], "surprise attacks" [Pearl Harbor].

People always say "no" to war, until there is no other choice...

How can nations prepare for surprise events without being pushed into war?
Post Opinion