Nationalism can't and shouldn't be avoided. A group of people on the same chunk of land with the same history have the right to govern themselves. I know my country is crushing Nationalism around the world, but I'm not the president and it's not my fault.
Alliances are to protect from attack from other nations or to allow for international trade.
The First Gulf War was completely due to a stupid trade agreement with Kuwait the US never should've made.
9/11 and the Second Gulf War were due to Saudi Osama's reaction to the uncouth US troops quartered in Saudi Arabia for the first Gulf War.
In the beginning of the Imperialist Era, public opinion towards Imperialism was accumulated because of the "White Man's Burden."
We now know this was just a facade, and the real motivations were 1) US paranoia over Europeans 2) Dinero. Mucho dinero. Conquest. Power. TRADE.
Militarism? Merely an outgrowth of Imperialism at the time. It's not like countries were militarizing by building fences of anti-aircraft guns around their borders.
Austria started WWI by annexing the Balkans.
If they'd stayed put, there would've been no WWI. Or WWII for that matter.
If the US had never made trade deals with some countries like Kuwait or outright invaded others for MONEY, we'd see a sizable reduction to the wars occurring.
And an international war is impossible if countries never interact.