I was reading some interesting analysis - apparently the security services (particularly in the US) will inevitably pick up chatter if anything big is being planned, and pass the information on to the relevant country's authorities. But the lone wolf vehicle/knife stuff is impossible to pick up on, they're unlikely to be telling anyone so there's zero warning.
Better mental health services would probably have a role to play - it's obvious to me that is one of the factors at play here - but the sheer number of traumatised, disaffected men, struggling to integrate, is huge. How to you tell which ones present a danger to society?
And then there's the total wildcard stuff like the Saudi surgeon who was responsible for the Magdaburg attack - ostensibly an educated, integrated professional. Allegedlyl, the Saudis actually passed on intelligence about his extremist views, but they were ignored as the authorities thought it was an attempt to discredit him.
Vehicle barriers are I suppose necessary, but how depressing that they're needed. However even if you block off every major pedestrian area in every city and town, a determined lone nutter could just mow down children at a pedestrian crossing on the way to school or something.