It was a chainreaction. Long story short, the countries were pulled into the war because of agreements they had with their allies. This treaty is what caused the countries to enter WWI, to protect and defend their allied countries who were already in the war.