In a
free society, you can't guarantee that you will stop terror attacks. They do cause damage and mayhem, however that is strictly localised unless the government overreacts and introduces draconian measures in a mistaken attempt to find terrorists under every rock. The UK survived decades of terrorism (sponsored by some US politicians like Rep. Peter King, now so ferocious against terrorists) without relying on mass surveillance of the kind it is now engaged in, in partnership with the US. It's not necessary to stop the attacks, only to survive them. Your question is like asking: How can we stop the next war?
In fact the aims of terror are principally to provoke a government to introduce repressive measures and lash out, and in the process, damage itself and its credibility with citizens. I think the aims of Bin Laden were probably to induce terror, fear, and paranoia in the US, and unfortunately they have succeeded, probably beyond their wildest dreams. Huge amounts of money and numbers of lives have been squandered, and the only result has been a series of failed states half-way across the world, a casual disregard for the rule of law, and a growing surveillance state at home destroying the very ideas the US claims to represent.
It's time for the US to recognise that expanding the architecture of surveillance and engaging in an eternal war against an ill-defined enemy is not going to make anyone safer, quite the reverse.