Image copyright Getty Images Image caption The Windrush generation are named after the Empire Windrush ship which brought workers from the West Indies to Britain in 1948

As in every walk of life, mistakes happen in politics and policy.

And mistakes can happen by accident, sometimes out of negligence, or sometimes because no-one could quite have imagined the consequences of actions that they decided to take.

But what's unravelled in the last few days - where the government has been embarrassed, and the prime minister herself had to say sorry about how people whose home is Britain have been treated - is more than just a series of coincidental errors.

The home secretary and the prime minister herself have now both apologised for the Windrush fiasco. Without question a big part of the problem has been how the Home Office has applied the policy that was set by ministers.

Incompetence is an occasional feature of any enormous government department. It's not exactly unheard of for the Home Office to be not quite up to its enormous task.

In fact, almost any MP will tell you about the kind of delays and frustrations they hear from some of their constituents about the Home Office's handling of immigration cases, affecting all sorts of different nationalities.

But officials respond to and operate within the policies, and the climate set by their political masters. And to understand what's gone here it's worth remembering that the rules that now seem overly draconian and unnecessarily burdensome were conceived in a particular political climate.

In the days of the coalition, the government's target of getting net immigration down to below 100,000 seemed pretty much unachievable. But the then Prime Minister, David Cameron, had told voters in 2010 that he would cut immigration or deserve to be kicked out.

He was determined to stick to the aim, despite a myriad of warnings that it was unrealistic and misleading to suggest the government had any hope of hitting it.

Theresa May was the politician charged with trying to meet what seemed an impossible goal.

Media playback is unsupported on your device Media caption Theresa May's Windrush apology to Caribbean leaders

The hunt was then on, under her leadership at the Home Office, to try to find every single possible way that could cut the levels of immigration, whether cracking down on people coming here illegally, or dealing with the problem of over-staying - where people came to the UK to study or work on time-limited visas but stayed.

Of course, neither of those categories relate to the Windrush generation, but they meant that slowly but surely government policy towards anyone whose status might be unclear or undocumented became tighter and tighter.

And the extent of action to try to monitor immigration extended into more areas of government activity. The rhetoric got tougher and tougher too, with David Cameron even warning illegal immigrants in 2014: "When we find you, and we will find you, we'll make sure you are sent back to the country you came from."

At times it felt then the two main parties were in a bidding war over who could sound tougher on immigration. There was unease, particularly on the Labour side, but the political wind certainly blew towards a tougher and tougher approach.

One of Nick Clegg's former advisers, Polly McKenzie, revealed online tonight how in 2012 it seemed inside government that part of the Home Office's effort to crack down on immigration was to make "it systematically difficult to get by without papers".

Media playback is unsupported on your device Media caption A look back at life when the Windrush generation arrived in the UK

This was of course an effort to cut the numbers of people who were here illegally. But over time, that meant people who had every right to stay in Britain, in their home, came under pressure too.

Some of the ideas were resisted. We revealed in 2016 that the now prime minister had even wanted at one stage to put the children of illegal immigrants at the bottom of the list for school places, but push back in Cabinet stopped that idea.

But it's clear that for years, there was a huge focus in government on looking for ways of cutting the levels of immigration.

And it's the drive to achieve that, not just administrative mistakes in the Home Office, that is now revealed to have caused such anxiety for so many people.

The Windrush fiasco is in part a by-product of a wider political trend that pushed policy over many years.

The government promises now that the personal injustices it's caused will come to an end - whether it calls time on the wider culture is a different question.