When countries join together, they form an alliance. Alliances can be for trade, militrism and other things etc.
The major cause of the Great War was the assassination of Archduke Franz Ferdinand of the Austro-Hungarian Empire in June, 1914, by Gavrilo Princip, a Serbian nationalist. The underlying causes of WWI were nationalism, a form of extreme patriotism and the desire to have independence among the Balkan territories; Imperialism, the desire to take over or gain control of other areas in the world; militarism, the arms race between the major powers; and the Alliance System that was military and defensive which drew all the major powers into the conflict because of their treaties with each other.