Some of the best thrillers depend on the audience knowing in advance that a deadly outcome is unavoidable. We sit, watch and wait, gripped with fear as the inevitable end looms. And often the characters suspect they are making the wrong moves but cannot stop themselves from doing so.

The same pattern applies in politics. Governments tend to make the same colossal mistakes as their predecessors. Leading figures recognise the errors when they were committed the first time around but then proceed to make a similar set of misjudgements. It's as if they are trapped by dark forces beyond their control.

This is what has happened with David Cameron's response to the crisis in Libya. He watched the first time around, recognised the mistakes and repeated them. The invasion of Iraq was on a much bigger scale and conducted without the support of the UN. Nonetheless, there are precise parallels with Libya. George Bush and Tony Blair invaded Iraq without having a clear outcome in mind. Their official war aims as far as they were specified did not include the removal of Saddam, although that was the outcome they hoped for.

Both leaders assumed that Iraqis would welcome them as liberators and that democracy would follow. As with the earlier war in Afghanistan, Blair declared that financial costs would be relatively low. In the build-up to Iraq, most newspapers hailed Blair for his political courage, even though he was siding with the most powerful military force in the world against an ageing tyrant. We know what followed.

More importantly, David Cameron knew what followed. Friends of Cameron insist he had deep doubts about the war in Iraq at the time, although he voted for it. Later, as Leader of the Opposition, he made one of his best speeches, during which he argued that a lesson of Iraq was that countries could not be bombed into democracy. With Cameron it is not always easy to judge whether he meant what he said or was seeking crudely to widen his party's appeal by belatedly marking distance for Iraq. Still, that was what Cameron argued, in an extensively briefed speech. I recall talking to him at length about it at the time. We must presume he recognised complexity and nuance as the calamity of Iraq unfolded.

Yet earlier this year Cameron rushed to the Commons to make an emergency statement. He supported a no-fly zone over Libya and had taken the lead in securing it. The aim was to protect the Libyans but he hoped the outcome would be the removal of Gaddafi, although this was not an objective. The cost would be a few million pounds. In large parts of the media Cameron was hailed for his leadership and courage.

A few months later and we are in another familiar phase of the pattern. The dictator is still there. The alternative might well be as unsavoury. Questions are being asked about why military action is taken in Libya, but not in Syria.

Here the Defence Select Committee estimates the costs of the campaign have exceeded early predictions and have already risen to beyond £200m. There is no end to the conflict in sight, so that figure will continue to rise. The same committee calculates that the cost of Afghanistan to the UK Government has been at least £18bn and it is probably a lot more than that.

Cameron and George Osborne argue that spending went out of control in the early years of this century. They may have a case, but in terms of the specifics they supported all the areas where expenditure rose. One of them was the cost of fighting major wars. Here we go again.

Why do political leaders stride into the same trap, having resolved not to do so when witnessing the fate of those that went before them? Cameron is not the first to do so. On the domestic front in the 1970s there was a similar eerie pattern. Ted Heath got into fatal difficulties as he attempted to impose a pay policy. His opponent, Harold Wilson, was scathing until he won an election. Shortly afterwards, he also imposed one. Jim Callaghan was also sceptical but succumbed in the same way and was brought down by it. In the end, all three Prime Ministers followed the same deadly route having resolved not to do so. They could see no alternative. They were too scared of breaking with corporatist orthodoxy. Having been brought up politically in the 1930s, they feared the social and economic consequence of high unemployment.

On Libya Cameron could see no alternative. He feared a slaughter. He is the heir to Blair and as he contemplated what to do about Libya, he reflected on his hero and what he would have done. Cameron was brought up politically at a time when Britain deployed military force without asking too many awkward questions. Now he is trapped, just as the leaders in the 1970s were in relation to their economic policies.