Visiting El Salvador over the past year, it was hard not to think the country's number-one job is standing around outside with a gun. In the region from which child migrants are fleeing to the US, personal security is largely a question of what you can afford to pay. El Salvador has, by one estimate, 25,000 private guards in a country with 20,000 police officers. In Honduras, which boasts the highest murder rate in the world and has seen the largest exodus of young people to the American border this year, guards outnumber cops five to one.

Wealthy Salvadorans can retreat to residential compounds that resemble a militarized version of a Palm Beach retirement community, complete with golf carts. Behind high walls and even higher voltage wires, one economist gushed to me: "This place has everything – we never have to go outside!" For the rest, those who stay and those who get sent back, gangland drama is a fact of life.

For Americans behind our own wall, there is a sense of bewilderment. We wonder why these young people are showing up at our borders, if they are enticed by some false promise of amnesty. And then we send them back.

But child migrants escaping north are not so irrational, and the current wave is neither new nor terribly mystifying. The factors that push and pull them – extreme violence, extortion, forced gang recruitment and a desire to reunite with family – are rooted in the United States's heavy hand in the region.

Central America didn't always have a gang epidemic. That was exported there by us. And the current immigration crisis is as much a United States legacy as it has become a local tragedy – a consequence of US-financed civil wars from the 1980s that sparked the first migration wave, and of US policies toward those migrants after they arrived.

The origin of MS-13's trademark devil-horns hand sign comes from an English-language metal band and the streets of Los Angeles Photograph: Ulises Rodriguez / EPA Photograph: Ulises Rodriguez/EPA

Both major gangs now plaguing the region originated in Los Angeles. The gang that became MS-13 was originally an informal collection of teenage civil war refugees and metal-heads who borrowed their devil-horns hand sign from Judas Priest. Their onetime ally-turned-rival, Mara 18, traces back to the 1940s but shared with the newer gang an open-door membership for Central Americans that put them both at odds with the area's more established, exclusively Mexican gangs. When those gangs began to terrorize the new immigrants, MS-13 and Mara 18 fought back. Only later would they spread to the countries which their parents had left, through deportations, and contribute to today's migration wave.

In time, MS-13 and Mara 18 came to surpass their oppressors, thanks in part to a citywide police sweep that preceded the 1984 LA Summer Olympics, busting up the known Angeleno gangs but overlooking the new Central American rivals – and also their propensity for violence, notoriously favoring machetes for attacks.

These street battles would have been of little concern to most Americans were it not for President Clinton and his desire to triangulate Republicans on crime. In 1996, he signed a law that ratcheted up deportations of immigrants with criminal records – including legal residents – by making things like drunk driving and petty theft deportable offenses.

Shipping off undesirable immigrants proved enormously popular among Democrats and Republicans alike, and mass deportations continued apace under Presidents Bush and Obama – overwhelmingly to Mexico and Central America. According to Homeland Security data, annual criminal deportations to El Salvador, Honduras and Guatemala have since jumped more than five-fold, from 1,987 in 1995 to 106,420 in 2013. Add the non-criminal deportation boom that will explode this year should Obama get the expedited deportation authority he's currently seeking, and you'll have the makings of yet another migration crisis just down the road.

Of course, deporting hundreds of thousands of criminals has been far less popular in the countries to which deportees are sent "home" – to a place many left as toddlers and do not remember. Mostly unemployable, some speaking little to no Spanish, many reconstituted their maras in countries ill-prepared to deal with them, still in the midst of postwar reconstruction, with underequipped and easily corruptible police in only nominal control of public safety.

It's a cycle: With each planeload of deportees, the gangs grew stronger, expanding their activities and recruiting younger members by force – taking a page from the armies Washington had backed a generation earlier – and it is precisely those children they target who await processing in our border detention facilities today.

Once again, migrants fleeing a conflict zone we helped create are showing up at our doorstep, and our solution, once again, is to send them back. Basic humanity dictates that we consider the plight that brought them here, and that we prioritize family reunification. So, too, does the law – one which Congressional Republicans, who routinely charge Obama with not enforcing immigration law, are now clamoring for him to ignore, and Obama remains just as eager to oblige them.

During El Salvador's recent presidential elections, the opposition party posted billboards in regions from which the largest number of migrants are leaving. Under pictures of Salvadoran families in DC, California and New York read lines like I WANT TO RETURN TO A COUNTRY FREE OF GANGS. It's an ambition unlikely to be realized as long as the US believes we can deport our problems away, because eventually, those problems tend to come back to haunt us.