In my opinion, the most important reason for World War I was balance of power politics, not colonial rivalry.
During the years before the war, Germany was intent on getting its "place in the sun." This meant that it was pushing to become a stronger and more respected country. This included actions that caused colonial rivalry.
The other countries of Europe engaged in alliance building and an arms race, as the first answer says. But what is important is why they did that. What they were mostly trying to do was to ensure that no country or alliance became so powerful that the others could not defeat it if they all banded together.
So the real cause of the war is Germany's desire to grow in power and the desire of most countries to maintain a balance of power in Europe.