They were hanging up the bunting in Mammoth Lakes this week, celebrating Independence Day in the traditional small-town fashion. First, locals queued up for an eat-all-you-can-eat "pancake breakfast". Then they took part in a fiercely contested "hot-dog-eating contest". Finally, after witnessing the annual town parade, the community oohed and aahed over a short but patriotic fireworks display.

Yet behind the show of civic pride lay a palpable sense of unease. For all the conspicuous consumption of junk food, and the proudly worn stars-and-stripes paraphernalia, locals were grimly aware that their picturesque resort, in California's Sierra Nevada mountains, was making headlines for all the wrong reasons.

The previous day, local councillors voted unanimously to seek bankruptcy, after Mammoth Lakes found itself facing a bill of $43m (£28m) from a botched property deal. The town, in winter a popular ski destination, became the state's second municipality in a less than a week to suddenly declare itself insolvent. Officials issued a statement claiming "bankruptcy, unfortunately, is the only option left", after a court ordered it to immediately pay the $43m to its largest creditor. It remains unclear how local police, firefighters, and core services will continue to be funded.

Mammoth's debt, which amounts to roughly $5,000 for every man, woman and child who lives there, and is more than twice the council's annual operating budget, arose in the most parochial of fashions: the town was successfully sued for breaking a contract with a local real estate firm which wanted to build a hotel complex near its small airport. But fallout from its troubles is being felt far and wide.

The insolvency occurred just days after Stockton, a commuter town east of San Francisco, became the largest US city in decades to file for insolvency, having built up debts of between $500m and $1bn. Worried analysts are now wondering if the two quick-fire bankruptcies represent the start of an ugly trend that could be about to accelerate – with devastating effects.

Fears over civic bankruptcies stretch back to December 2011, when a high-profile Wall Street analyst called Meredith Whitney caused an overnight panic in the municipal bond market, which underpins America's public fortunes, by telling the TV news show 60 Minutes that she believed that there were going to be "50 to 100 sizeable defaults" by debt-ridden cities in the not-too-distant future.

Whitney claimed the nation's local administrations were operating in a collective deficit of something like half a trillion dollars. In addition, they had underfunded pension liabilities of another $1.5 trillion. If large numbers were to fall into insolvency, and begin defaulting on bond payments, she believed the financial system could suffer meltdown on a scale similar to the sub-prime mortgage crisis.

Since 2007, a series of small cities – from Westfall in Pennsylvania, to Moffett in Oklahoma, and Prichard in Alabama – have found themselves in court declaring "Chapter Nine," the part of the US bankruptcy code applicable to municipalities. Whitney believed that trickle could become a flood. And if a meltdown were to happen, she said that it would gather pace in the state with the nation's highest public debts and most dysfunctional government: California.

Little wonder, then, that the sudden bankruptcies of Mammoth Lakes and Stockton have raised eyebrows. Some experts say they are at the extreme end of a trend which, while serious, can be avoided through fiscal reform in a now-growing economy. Others, shaken by Stockton's attempt in court this week to become the first US city to impose losses on bondholders, wonder if Whitney was right – and if an entire house of cards is about to fall.

Richard Ciccarone, a specialist in municipal bond research for McDonnell Investment Management, is among the optimists. But he recently analysed 2011 data from 124 of 500 Californian cities. He told The Independent that around a dozen (roughly 10 per cent of his sample) are now "extremely vulnerable" to bankruptcy.

In seeking to identify candidates for civic insolvency, he looked for low liquidity levels, steep declines in home values and a high "public safety ratio," the portion of spending that a city devotes to police and fire services. "When cities cut budgets, police and fire tend to be the last to suffer," he says.

Administrations most vulnerable to insolvency spend up to 80 per cent of budgets on "public safety," Ciccarone says. When further squeezed, they can end up in a sort of fiscal death spiral: cutting public safety budgets increases crime and makes them less attractive places to live, meaning that affluent residents move, further reducing tax revenues. "We saw a similar process happening in the Rust Belt, in the 1970s and 1980s," he says.

One such city is Stockton, whose current difficulties stem from years of short-sighted policymaking which has left the city of 300,000 residents facing an annual bill of $20m to merely service its soaring debt. For years, it pursued a policy similar to that of Vallejo, a Californian neighbour which went bankrupt in 2008: at almost every opportunity it granted inflation-busting pay rises to police, firefighters, and other public workers, without raising taxes on residents.

In boom years, as property tax revenues soared, that profligacy seemed appropriate. Stockton's house values quadrupled between 2000 and 2006, allowing the city of 300,000 residents to spend like a drunken sailor: $47m on a loss-making sports arena, $100m on a smart marina. But with the bust, home values fell back to 2000 levels and revenues fell accordingly.

The city was left with foreclosure rates of just under ten per cent, 15 per cent unemployment, and no way to meet the financial obligations it had built up during the good times. It began reducing retiree medical benefits, closing parks and libraries, and sacking police and fire officers. Crime rose, poverty grew, and a vicious circle began to turn.

Mark Paul, co-author of a book called California Crackup: How Reform Broke the Golden State and How We Can Fix It, argues that the seeds of the bankruptcies of Stockton, and to a lesser extent, Mammoth Lakes are rooted in Proposition 13, a ballot measure passed in 1978 which froze property taxes and introduced a requirement that a two-thirds majority in the state's Senate vote for any major tax increases.

Despite passing the law, Californians continued to demand expensive services, causing city, state and regional administrations to slowly clock up ever-greater debts. Twenty-five years into that experiment, he says that if more bankruptcies are now to be avoided, with the wider calamity that could bring, he says residents must confront an awkward reality: good government never comes for free.

"A something-for-nothing mentality is encouraged by our system," he says. "That will only change when politicians start being honest and tell people that if they want proper services they have to be prepared to pay for them. The recession pulled the covers off problems which have been festering for a long time.

"At the moment, everyone is left wondering who is going to be next to bear the brunt of the pain."

The towns left in financial ruin

Stockton, California

The biggest city in the US to run out of money so far, it listed a debt of $1bn in its bankruptcy application last month

Mammoth Lakes, California

The ski town filed for bankruptcy this week after losing a legal fight costing twice its annual budget

West Fall, Pennsylvania

The economy was doing well in this small town yet its $20m debt still proved too big for it to cope with

Jefferson County, Alabama

Failure to restructure $3.1bn bonds on its sewers sent its finances down the drain

Central Falls, Rhode Island

Went broke last year due to its massive pension bill for the baby boomers among its 18,000 citizens

Vallejo, California

Debt led to police officers being laid off, fire stations being closed, and cuts imposed on other services in 2008

Moffett, Oklahoma

Raised 78 per cent of its income from speeding tickets – until a state-imposed ban on the fines made it insolvent in 2008

Pritchard, Alabama