People like the Serbs, Bosnians, Croats, and Slovenes wanted independence.
A man named Archduke Franz Ferdinand, heir to the Austro-Hungarian throne, was assassinated by a Bosnian, who was a member of a Serbian nationalist group. The country wanted to get revenge but the government knew that attacking could cause a war between with it's ally, Russia.
We love our country!
Nationalism became a popular and powerful idea to the Europe's by the late 1800s, many people went to war willingly to expand their own nation.
Alliances were often made to ensure common goals and secure common interests, especially by Europe due to paranoia.
Germany had planned on sneaking through France to fight Russia, only for Russian troops to invade an attack. Which ended up in some retreating. Ally Austrian with Germany were more successful than Russia in the end.