This is a good question for the observation that Foch’s speculation being accurate, but not necessarily for the right reasons.
But first: how did he do it? Foch joined the French Army in 1870 – the year of the Franco-Prussian War. The recurring competition between France and Germany (in one form of another) was the primary politico-military development driver for the Continent since the Middle Ages – it was the dominating feature for military thought on both sides of the frontier. It may be argued that Prussia (later Germany) was for practical purposes all Foch ever thought about. With such a dedication to a subject, and given his position in the French Army. it would have been surprising if Foch did not have an opinion on the next development of the conflict, and it is not inconceivable that such an opinion would have had an element of accuracy about it.
But why is this? For the simple reason that when all these Franco-German conflicts are abstracted out, it becomes evident that nothing had changed with the First World War. The reasons for the animosity had not been altered, and in many respects, the Treaty of Versailles made things infinitely worse - but not enough. Therefore, it is possible to reason that the drivers for continental conflict were if possible, even stronger before the Second World War than before the First World War (but probably with less popular displays of such sentiments).
Is this why some thought the Treaty too harsh? It may be, but the motivations for creating an opportunity for Germany to recover are diverse. It is for instance recognised that a strong European economy requires a strong German economy, and that France was ‘shooting herself in the foot’ in this respect, since her own economy would struggle to recover whilst the German economy was weak. The British strategic driver is even more complex – Britain has a long geo-political history of aligning with the Second Continental Power against the Prime Continental Power, and an even longer political history of Francophobia. At an instinctive level, Britain would probably have wanted to edge away from a solution which set the Continental Balance of Power in stone.
Why did some (like Foch) feel that the Treaty was too lenient? Aspects of the economy aside, Foch knew that life for his military descendants would be substantially easier with a permanently weakened Germany. Germans used to have this terrible practice of turning a strong economy into a strong army, and of turning a strong army into misery for the French Army. It may be argued then that Foch did not represent France as the current victor, but the potential future vanquished – if there had to be any chance of a German recovery, France was sure to suffer in the extreme again in the period thereafter. As stated earlier, this clarity was due to the realisation (if only at a common-sensical level), that the drivers for the competition had not changed.
Having failed to persuade the Treaty authors of this need to gut Germany completely, so to head the next round off at the pass, Foch understood that it was now given that there would be a 'next round'. It was now purely a matter of estimating the time remaining until it would start. The ‘short-hand’ for this was the amount of time Germany would require to recover her economy under the Treaty. However, there were certain events of this predicted period which had a profound impact on Germany’s economic revival that Foch could not have foreseen: the Great Depression acted as an antagonist, as did the great political instability of the Weimar Republic. Other events and developments acted again as agonists: the great technological advancements relating to mechanical and civil engineering, a resurgence of social polarisation, and the emergence of political extremism. It just so happened that these antagonists and agonists balanced one another out exactly to meet Foch’s speculation.
Therefore, it is safe to argue that Foch’s prediction was accurate, but for the wrong reasons. In addition, his was in all probability an off-the-cuff comment that is only remembered for coinciding with his future. If Foch had estimated 30 years to the next war, we would not be discussing this right now. In fact, it is almost a given that Foch made other speculations which are no longer remembered for this exact reason. In this respect this snippet of history can be contextualised an example of Survival Bias.