How did Germany lose WWI if they were not invaded and still had a large amount of soldiers on foreign soil?
Germany's population was on the brink of revolution at the end of WW I. Their navy had already mutinied once and whole battalions were breaking up as the stress of over four years' of war was taking its toll. Germany had huge casualties and now they were being pushed back towards their own country. They were no longer attacking towards Paris. With the entry of the US, a fresh country with a large manpool and a huge industrial base, even the rank and file German could see they were going to lose the war. They didn't want to fight knowing they were going to lose and the morale of their army had just about been broken. That's why units were disintegrating.
The High Command and Government saw what was happening and that is what convinced them it was time to surrender before a revolution like what was happening in Russia happened in Germany. They approached the Allies and asked for their terms and they were harsh, but at least Germany remained a single entity. The Austrian and Ottoman Empires did not fare as well and both were broken up and lost huge amounts of territory.
We interrupt Germany WWI to share caption from days of old:
Today is: 23rd October (GMT), in history on the 23rd of October, 1954 AD the following event happened:
Pakistan Governor-General Ghoelan Mohammed disbands parliament