The overall reason of the German defeat in World War I was their inability to sustain a prolonged war of attrition, while the Allies could.
By the late war 1917-1918, the generals of both Allies and Germans knew they had to change their tactics in order to win the war. Ludendorff devised the plan of advancing quickly using specialised fast infantry called storm troopers. This was not a sound long term plan that would win them the war. Short term gains of land would be made by them and they proved effective, however due to their rapid advancement they would frequently overshoot their support and supply lines. Therefore they would usually be wiped out, causing failures in the German war plans, and thus leading to their defeat on the western front in 1918.
The German defeat in WWI was partly attributed to their inadequate home front in the late war. By 1918, most towns and cities were in revolt, and mutinies were experienced throughout many parts of the country-the first being the docks at Kiel. Because of the unrest throughout the country, it could not provide munitions or support for the western front towards the end of 1918. Raw resources were always scarce, but to add to this the Allies had blockaded Germany since 1917, creating a desperate situation for Germany's war effort. Therefore the limitations of the home front significantly contributed to Germany's loss in WWI.
One of the flaws to the German leadership during the war was that military decisions were often influenced by political factors and goals, which would inevitably lead to problems in their war plans. An example of this was when Russia surrendered to the Germans in 1917, Germans left 500,000 of their troops in Russia as an occupying force. This aggressive expansionism by Ludendorff proved to be a fatal mistake as had these troops been reallocated to the western front, they could have potentially succeeded in their Spring Offensive.