John Maynard Keynes published his most important book, 'The General Theory of Employment, Interest, and Money' in 1936, and died a decade later in 1946. So we have to understand Keynesian economics within the context of the aftermath of the Great Depression in 1929, when he wrote the book, and when unemployment was somewhere between 25-33%.
The argument between Keynes and his detractors centres of whether to prioritise unemployment or inflation. For Keynes, the issue was that economic systems, if left to their own devices, simply can't cope with boom and bust. Given this, the state must intervene. Keynesian economics says that getting people working is more important than worrying about inflation, because the economy is like a depressed person and needs help to recover.
This works fine assuming the economy grows plenty in the future. A rapidly expanding economy inevitably has high inflation, and this helps take care of the debt problem of government spending in the short term. Especially if this money is invested mostly in infrastructure, which, like scientific research, has a very high return on investment.
The same logic motivated Roosevelt's New Deal in 1933, that spending on infrastructure projects in particular would help to get people back in work and thus get the country back to an optimistic state.
Britain's 1945 general election was won by the Labour party, promising an essentially Keynesian plan, with massive public infrastructure projects, slum clearance, housing construction, nationalisation of industry, etc.
The Labour party was twinned with the labour union movement, and as such worked to provide and then secure employment for their members. This they reckoned was best for individual and society, as unemployment was regarded as something on par with poverty, ignorance, or malnutrition.
After the war Britain was broke. In 1940 the British Empire conducted the largest wealth transfer in history, by moving an enormous quantity of money and gold to Canada to buy American war materiel. When the war began Britain had also inherited a sizeable debt from the First World War, a sum it was still repaying (a sum which was never actually fully repaid to American creditors given the outbreak of the Second World War).
Britain's public debt in 1945 was just shy of 250%. And then the British government went on a spending spree. The consequence however was that living standards improved and government debt steadily declined.
Things were going so well that in 1957 Conservative Prime Minister Harold Macmillan said "You've never had it so good". This he put down to increases in the productivity of major industries. Not to mention the benefits of a society where everyone had access to university education.
By 1972 public debt was just under 50%. So for that era, Keynesian economics worked just fine. In the 1950s Britain actually had labour shortages, and so tried to hire workers from the Caribbean.
However, nobody expected Stagflation. In 1965 Conservative politician Iain Macleod famously said:
"We now have the worst of both worlds—not just inflation on the one
side or stagnation on the other, but both of them together. We have a
sort of "stagflation" situation. And history, in modern terms, is
indeed being made."
The 1970s would see considerable economic disruption and uncertainty, and the Keynesian model didn't help. The British government tried to manage wage rises against inflation, given state ownership of industry meant the state employed so many people. Because the Labour government was born of the labour union movement, it found itself unable to negotiate with labour unions successfully, and repeatedly gave in to above inflation pay rises, which made things worse.
This crisis escalated into the Winter of Discontent in 1978, Margret Thatcher's Conservative election victory in 1979, and the end of British socialism shortly thereafter. Thatcher would adopt a Monetarist view, and prioritised inflation over jobs, which meant the Keynesian era was over.
To conclude, Keynesian economics worked in Britain after the war, but it wasn't able to predict or adapt to the realities of stagflation which emerged in the 1960s. Like all economic plans, it is situational and has a limited shelf life. If an economy can expand rapidly with large infrastructure projects, and suffers from high unemployment, then it can probably work for a decade or two.