One madman has caused carnage with one truck. Had a squadron of armed police been stationed on every street in the West, unless they were armed with bazookas, how could they have prevented it? Even then, you can't blow up an approaching truck on suspicion, can you, until he ran people down, there was no way to think that was his intention.
The sad fact is that such attacks simply can't be defended against. There are billions of vehicles on the roads, and any one can be used to kill at any moment. It is necessary to rely on the fact that lunatics ready to commit such outrages are pretty rare in the West, because there is literally no way to prevent them. Nor is there any shortage of novel ways to cause carnage, if you have a mind to. Sadly, in the world, there's no shortage of such people. We have so far been relatively insulated from terror, but elsewhere, mass killings are a daily occurrence and as the ratio of nutters increases, so will violence generally and mass killings in particular.
You can offer some protection to your population if you have extensive intelligence networks and surveillance, and to some extent we do, which is sometimes able to prevent plans being carried out, but the problem with that is it doesnt sit well with privacy or civil liberties and freedoms, and there's the difficulty. Nobody wants to live in a police state.
And of course the other side of the propaganda coin of ISIS claiming the Nice job as theirs, when it seems most unlikely, is the inevitable conspiracists who predictably and with relish trot out their favourite phrase, "false flag" claiming that ANY terrorist killing was in reality done by the government, to smooth passing ever more surveillance etc laws by softening up public resistance to the idea. They were at it within minutes of the Nice news.