Germany had been preparing for war long before 1914. In fact, Germany had started drawing up a plan for war - the Schlieffen Plan - in 1897. It took nine years to finalise, but it was based on the theory that Germany would be at war with France and Russia at the same time. It did not prepare for many of the events that occured in July and August 1914. It was based on the belief that, if the country went to war, Germany would be faced with a war on two fronts with France and Russia.
The plan assumed that France was weak and could be beaten quickly, and that Russia was much stronger, but would take longer to mobilise its army.
The plan began to go wrong on 30 July 1914, when Russia mobilised its army, but France did not. Germany was forced to invent a pretext to declare war on France (3 August 1914).
Things got worse when Britain declared war on Germany on 4 August 1914 because Britain had promised to defend Belgium in a Treaty of 1839.