Answer:
The immediate cause of World War I that made the aforementioned items come into play (alliances, imperialism, militarism, nationalism) was the assassination of Archduke Franz Ferdinand of Austria-Hungary. In June 1914, a Serbian-nationalist terrorist group called the Black Hand sent groups to assassinate the Archduke.
Secret alliances were formed prior to the outbreak of the war. After the Assassination of Franz Ferdinand the Archduke of Austria-Hungary the alliance systems went into effect leading to many nations protecting one another (i.e. Russia protecting Serbia from Austria-Hungary).