How important were treaties and military alliances in causing world war I?
The single largest contributing factor to the 'world-wide' aspect of World War I was treaties that resulted in entangling alliances. An alliance is when two or more countries agree to help each other out if needed.
Before WWI, many of the countries in Europe had formed alliances with each other. Some of the alliances were well-known, and some were secret. When Archduke Franz Ferdinand of Austria-Hungary was assasinated by the group the Black Hand, (Serbian Nationalists), Austria-Hungary declared war on Serbia. Austria-Hungary, a huge powerful country in Europe, felt pretty good about this, because Serbia is relatively small and weak. Austria-Hungary had already formed a powerful alliance with Germany, but they did not count on Serbia having an alliance with Russia.
So...this is what happened, because of the entangling alliances:
Austria-Hungary declares war on Germany
Russia announces their intent to moblize the army to defend Serbia
Germany views Russia's mobilization of the army as an act of war against Austria-Hungary and declares war on Russia
France (bound by a treaty to help Russia) declares war on Germany and also Austria-Hungary
Great Britain (in treaty that states a 'moral-obligation' to help France) declared war on Germany. Britain also had a treaty to help Belgium too, and Germany had invaded Belgium as well.
These entangling alliances drew in all the major countries of Europe. When you also factor in that many of these countries have multiple colonial holdings across the world, the war escalates from being a continental war to World War I.