As the furor grows over lenders’ efforts to sidestep legal rules in their zeal to reclaim homes from delinquent borrowers, these and other banks insist that they have been overwhelmed by the housing collapse.

But interviews with bank employees, executives and federal regulators suggest that this mess was years in the making and came as little surprise to industry insiders and government officials. The issue gained new urgency on Wednesday, when all 50 state attorneys general announced that they would investigate foreclosure practices. That news came on the same day that JPMorgan Chase acknowledged that it had not used the nation’s largest electronic mortgage tracking system, MERS, in foreclosures, since 2008.

That system has been faulted for losing documents and other sloppy practices.

The root of today’s problems goes back to the boom years, when home prices were soaring and banks pursued profit while paying less attention to the business of mortgage servicing, or collecting and processing monthly payments from homeowners.

Banks spent billions of dollars in the good times to build vast mortgage machines that made new loans, bundled them into securities and sold those investments worldwide. Lowly servicing became an afterthought. Even after the housing bubble began to burst, many of these operations languished with inadequate staffing and outmoded technology, despite warnings from regulators.

When borrowers began to default in droves, banks found themselves in a never-ending game of catch-up, unable to devote enough manpower to modify, or ease the terms of, loans to millions of customers on the verge of losing their homes. Now banks are ill-equipped to deal the foreclosure process.