In order to understand why a conflict that should have been just between Austria-Hungary and Serbia escalated in to a World War, it is necessary to consider the various alliances between countries that were in place at the time. Germany had an alliance with Austria-Hungary from the Dual Alliance of 1879 through the Dreikaiserbund treaty of 1881 (which also included Russia) to the Triple Alliance of 1882 (which included Italy rather than Russia). This explains why Austria-Hungary turned to Germany for help against Serbia. After the fall of the Reinsurance Treaty of 1887, German military relations with Russia deteriorated, and Russia instead joined the Triple Entente with France and Britain. Therefore, it was quick to mobilise against Germany and Austria in Serbia's defence. The alliance of the Triple Entente also explains to some extent why France mobilised so quickly once Germany had declared war against Russia. Britain joined the war mainly to honour the Treaty of London that stated that they would protect Belgium, and also their role in the Triple Entente meant that they assisted France. These various treaties explain somewhat how each country got pulled in to the war and the sides they took, but not completely because even though these treaties existed, they did not have to honour them, meaning that there were other factors which determined who ended up fighting in World War I.
Nationalism played a large part in the causing of World War, not just from Germany but nationalism from each country that participated. Nationalism became far more popular and widespread throughout the majority of Western Europe in the late nineteenth and early twentieth centuries, due in part to the increased belief in Social Darwinism, the theory of a racial hierarchy. Each country at the time was nationalistic, proud of their economy, industry, military etc. as well as patriotic, and this was shown and promoted at the time through nationalistic poetry, music and plays.