History is back in Europe. The Catalan referendum and the German election illustrate this spectacularly. The scale of the far-right vote in what was once East Germany and Catalonia’s apparent march towards independence may look like they happened on separate planets – to be sure, they are fuelled by different political beliefs – but they both have to do with pent-up frustrations. Citizens who feel that they have been insulted have gone to the ballot box, and in some cases taken to the streets, to protest. In both situations there is a vivid historical backdrop, with memories of Europe’s 20th-century nightmares playing an important role: in Catalonia, the fight against fascism and Franco; in the east of Germany, the experiences of Nazism and Soviet communism.

In Leipzig and the nearby small town of Grimma, I was told about how citizens felt their self-esteem had been trampled on. German reunification has not led to a shared sense of community. Rather, it’s compared to colonisation: “westerners” took over everything – regional administrations, courts, education and the economy. Everything about life in the Communist state – the way people dressed, what they ate, what they learned in school, how they decorated their homes, what they watched on TV – became an object of scorn and ridicule. It’s not that life isn’t better now: of course it is. There is freedom. And living standards have improved immensely. But many eastern Germans feel their identity has somehow been negated, as if they were being asked to forget about it.

Speaking with Catalan friends in recent days, I heard similar qualms: “We were waiting for a sign that our voice would be heard, but as the years passed nothing was changing” … “Our cultural difference isn’t being acknowledged as it should be”: these were common sentiments, even from people not altogether enthusiastic about breaking away from Spain.

Identity isn’t just about power, rights and institutions. Former East Germans aren’t asking for secession, nor a special status. Catalonia is deeply divided on the question of independence. Nor can identity be boiled down to purely economic factors – wages, income, jobs, social class. It’s true that regions covering the former East Germany have higher unemployment (7.1%) than western ones (5.1%), but the malaise reflected in the east German far-right vote went beyond material circumstances. Catalonia’s economy has thrived in recent decades – that hasn’t prevented protests.

A generation has passed since German reunification, in 1990; and Spain joined the European club in 1986. It’s hard to exaggerate the benefits. Anyone who visits Leipzig, with its beautifully restored facades and the amazing modern architecture of its university, will struggle to spot traces of the bleakness and poverty that once characterised eastern Europe.

Catalonia’s transformation has also been stunning. I have spent many summers in the Pyrenees, regularly crossing into Spain from France. And over the years I have seen roads improved, hotels built, and prosperity spread – a region shedding the drabness left by the Franco years. The 1992 Barcelona Olympics celebrated that success.

Yet these accomplishments don’t necessarily translate into people’s minds. The European project is built on the idea that economic ties and social improvement bring people together and help them overcome the traumas of history. In recent years, much has been said about how nationalism, populism and anti-establishment sentiment are a response to globalisation and inequality. Less has been said about a more specifically European ingredient: the shadow cast by 20th-century traumas born of war and totalitarianism, and the difficulty – which still persists – of dealing with that legacy.

It is this history that sets continental Europe’s populist convulsions apart from the forces that have driven Brexit and Trump. Britain and the United States never experienced life under fascism, or behind a version of the iron curtain. Across Europe, populism and extremism, whether of left or right, plunges its roots into 20th century political battles and references. Catalan nationalism, I think, is different from Scottish nationalism in this way also: it can quickly reignite memories of oppression that are still vivid within families – stories of life and death, in one’s own country.

When crowds in Barcelona start singing old songs of resistance against the Franco regime, history is back. It is also back when 22.5% of voters in the former East Germany (twice as many as in the western part of the country) cast their ballots for a party – Alternative für Deutschland – whose platform amounts to a rejection of everything Germany’s western-built democracy has stood for.

Last month’s German election was a clear demonstration that the Wall has survived in people’s minds. Germany and Spain today find themselves confronted by ghosts of the past – not just to do with problems related to social cohesion and integration, or how to preserve a constitutional order. Yes, politicians exploit polarisation. But it is striking to see how, over a generation after democracy was anchored in countries that had experienced the worse of the 20th century, so many citizens feel that so much has still been left unaddressed.

Isaiah Berlin once wrote that nationalism feeds on a sense of wounded pride and humiliation. As Europe tries to sort itself out and prepare for the future – including through grassroots “democratic conventions” due next year across the continent – it would do well to pay closer attention to those wounds left by history. We thought that they had healed – but they really haven’t.

• Natalie Nougayrède is a Guardian columnist