As a correspondent in Washington 20 years ago, I received occasional calls from local television stations on the anniversary of the burning of the White House by a British force in August 1814. The reason they wanted a comment was because the raid was jointly led by my distant ancestor, Admiral Sir George Cockburn, who took a fleet into Chesapeake Bay in the last months of the war that had started in 1812.

The intention was for Sir George and his fleet to seize horses in Virginia and Maryland for the cavalry. Instead, the sailors found it far more profitable to plunder tobacco warehouses on the creeks running down to the Chesapeake.

They also freed 300 slaves who, according to a British account, “were uniformly volunteers for the station where they might expect to meet their former masters”. Reaching the northern end of the Chesapeake, the British landed and advanced on Washington. British troops fought a brief victorious action against the American militia at Bladensburg in Maryland, where President James Madison had disastrously decided to exercise his powers as commander-in-chief. The dispersal of the militiamen was so humiliatingly swift that the battle became known as “the Bladensburg Races”. Occupation of the US capital, at this time inhabited by only about 8,000 people, followed immediately against no resistance.

In the captured city, Sir George showed a spirit of jocular derision towards the institutions of the young American republic whose public buildings he intended to burn down. The justification for the arson was that it was in retaliation for the burning by American troops of the Canadian parliament building a year earlier when they captured York, later known as Toronto.

Some 50 British soldiers advanced down Pennsylvania Avenue to the presidential mansion. Here they found an inviting dinner waiting for them, thanks to the President’s wife, Dolly Madison, who had been expecting to feed the victorious American defenders of Bladensburg. Forced to abandon the banquet at the last moment, she fled the presidential home. After dinner, the victorious British set the mansion ablaze. When the flames died down, only the exterior walls still stood and these were so weakened by the heat they mostly had to be demolished.

The burning of Washington was the high point of the campaign and the best-remembered incident in the War of 1812, as it came to be known. The British fleet moved north and bombarded Baltimore, an attack notable for inspiring “The Star-Spangled Banner”, whose allusion to “hireling and slave” may refer to the freed slaves in the British force.

The War of 1812 is not one Americans know much about (it has greater prominence in Canadian history). But the 32-month conflict vies with any other war fought by the US over the following two centuries, including Vietnam, Iraq and Afghanistan, for being poorly conceived and disastrously executed. Justified in the US as a reaction to the Royal Navy illegally impressing American sailors, the true motive was that Madison and his supporters thought it an excellent moment to invade and conquer Canada. In early 1812, Napoleon was at the height of his power, and Wellington in Spain was dependent on American grain.

But the US declaration of war turned out to be a masterpiece of miscalculation and bad timing. In the summer of 1812, a war alongside France against Britain must have seemed to Madison like betting on a certain winner. But the US declaration of war came just as Napoleon was starting his disastrous march on Moscow. By the following year the French were being defeated in central Europe, and Wellington was advancing into France. With the end of the French blockade, Britain was no longer reliant on American grain. The US invasion of Canada failed, and Madison achieved none of his war aims. “It remained to construct a myth,” writes the naval historian NAM Rodger, “which might allow Madison’s futile and humiliating adventure to be remembered as a glorious national triumph”.

It is the way that wars are remembered that gives relevance to the conflict between the US and Britain almost 200 years ago. Bookshops are full of military histories, but these often dwell on the exciting details of combat rather than why nations get into wars and how they get out of them. The incompetence of individuals is over-stressed in the interests of simplicity and melodrama. This is also true of books about US and British involvement in Iraq and Afghanistan over the past decade.

To take a disastrous British war from the 19th century rather than an American one, there are plenty of exciting accounts of the British defeat in Afghanistan in 1839-42. This was a conflict of great drama, and it is difficult to drive through the Kabul Gorge without thinking of the British and Indian soldiers and civilians being slaughtered in the snow. The fighting itself has been extensively written about, but there are few good modern accounts of why intelligent and well-informed British officials and officers launched a campaign in Afghanistan in 1839 that turned into a catastrophe. There is even less written about how the British government in the 1840s had the courage to cut its losses, rebut charges of military and political cowardice, and withdraw from Afghanistan.

No US president – in 1812 or 2012 – can admit to military defeat, so withdrawals have to be conducted under the pretence that intervention has somehow achieved its aims. The British media likewise gives little sense of the extent of Britain’s military failure in Afghanistan. The problem about denying that a disaster has happened is that it becomes difficult to stop it happening again.

PATRICK COCKBURN is the author of “Muqtada: Muqtada Al-Sadr, the Shia Revival, and the Struggle for Iraq.