If you note that firstly, Serbia was nominally allied with Russia over the annexation of Bosnia, then that gives a key impetus to the initial outbreak of war. And the alliance system, as you pointed out, cause pre-emptive declarations of war. The Italians also had a 1902 agreement with France which effectively removed them from the Triple Alliance with Germany and AH.
And there's the other issues such as British opposition to Germanys colonial and naval expansion; i.e. it's not solely down to nationalism IMO, but multiple political, military and social factors on top.