Just a minor addition.
Personally I think the biggest reason that governments, especially local governments get in trouble in lean times is what seems to be an institutional inability to plan for lean times (though in their defense, I have noticed many corporations and individuals have this problem as well). A few years ago when the coffers were over flowing in many (Though not all areas) due to inflated real estate prices, many state and local governments either increased spending to match their income or they cut taxes (It probably depended on the locality and what would be more popular with the local population). The problem is that both outcomes are hard to undo during lean times. If states start cutting too deeply during lean times, they can cause a cascade effect that makes the local economy even worse, thus decreasing revenues even more which results in more cuts and so on... if they raise taxes well, it gets people mad and also has the potential to hurt the economy.
Obviously the solution is that during times when they have excess income they should stash some of the excess a way so that they can build up a cushion for future down turns. The problem is very few people like those solutions.