It was because of the fact that European countries were allied to each other, that drew them into the conflict.
Militarism, or the building up of a nation's military, was done because Europe was nervous. Serbia built up it's military, which made Austria-Hungary nervous, so they built up their military, which made Russia nervous, so...and so on.