Suppose that there is an expanse of land, a small part of which is prone to flooding. Obviously no-one likes having their house flooded, and so people avoid building houses on the flood plain and instead they all live elsewhere.
Gradually, the population grows and so there is greater pressure on the land. People start to think about building houses on the flood plain. But they are still wary of flooding. The problem is, of course, one of public goods. Building flood defences would protect numerous houses, but there would be no way to charge anyone who refused to pay.
Except... at this moment, there is. The houses have not yet been built, which makes it highly feasible for a single entrepreneur to buy up an area of flood plain sufficient for building numerous houses. He then builds flood defences and sells off the land at a vastly higher price than that for which he bought it.
But what if this isn't the scenario, and the houses have already been built? This could happen in a number of ways: perhaps there was an implicit state subsidy for living on the flood plain through the guarantee of being rescued for free by emergency services. Perhaps people didn't mind being flooded quite so much when they had fewer possessions, but as material wealth increases so does the cost of being flooded. Perhaps there was a genuine market failure with poorly-designed incentives at an insurance company. The point is that it is now infeasible to buy up the land and then sell it at a higher price. People are not likely to be willing to to sell their own house and then buy it back at a higher price. Moreover, this wouldn't even overcome the public goods problem now, because someone could hold out on selling and still free-ride on their neighbours paying (indirectly) for the flood defences.
This is the point at which many people - including people who are generally rather pro-market - would call "Public Goods Problem" and call the state in. I'll admit that it took a fair bit of thinking for me to work out the solution, and there are still a few kinks to be worked out. The solution I came up with - there may be others - lies in insurance.
Let the cost of insuring a house against the risk of flooding be P1. Let the cot of insuring a house against all other risks against which it is worth insuring the house be P2. Let (the cost of erecting flood defences, divided by the number of households benefiting from the defences) be P3.
The prevailing market rate for insurance will be P1 + P2. This means that an insurance company (which we shall call Flood Plain Insurance Ltd, or FPI) could make a profit by offering a price P4 to all people on the flood plain, where (P2 + P3) > P4 > (P1 + P2). (What if such a price does not exist? I'll get to that later). People will flock to buy insurance from FPI due its lower prices; once everyone (or nearly everyone) has transferred to FPI, they build flood defences. The cost of insurance to the company is reduced to (P2 + P3), and so the company makes a profit.
What if there is no price which will allow this profit? If there is no price P4 satisfying (P2 + P3) > P4 > (P1 + P2), then this means that
(P2 + P3) <= (P1 + P2)
Remove P2 from both sides:
P3 <= P1
And we see that the building flood defences is at least as costly as insuring the houses, if not more expensive. Under these circumstances, it is not worth building the flood defences.
Given all this, we must ask: why doesn't this already happen? Why don't insurance companies already carry out this kind of scheme? I see three possible explanations:
First, if the barriers take a number of years to pay off in terms of reduced cost of insurance and insurance is bought on an annual basis, then FPI may not gain sufficient revenue in one year to pay for the defences profitably. This is a problem because once the defences are built, any company can charge a reduced insurance fee since there is little/no risk of flooding regardless of who sells you your insurance.
The most obvious fix to this would be for the insurance company to insist on selling five or ten year insurance contracts - freely transferable to anyone who buys the house - as a condition of the cheaper prices. My suspicion is that some home-owners would prefer to have greater flexibility and would refuse such a contract, which would threaten this idea. Selling insurance futures would probably be too complicated for most people's liking. I don't know how exactly to solve this, but I would suggest that it is likely to be a small problem - hopefully the people who refused long-term contracts would be a minority.
The second potential problem is transaction costs. FPI would need to advertise its insurance to everyone on the flood plain and go through the whole process of signing everyone up. The government, by comparison, could just build the defences.
That said, there are also costs to the government doing things. Most obviously, problems like the dead-weight cost of taxation, but the government also needs to carry out a cost-benefit analysis whereas FPI needs only turn a profit. It seems unlikely that it is genuinely cheaper for the government to build the defences than for FPI to do so. If transactions costs are what stops the defences from being built, then perhaps we have to just accept that no system is perfect, not even the free market, and that in this case the benefits of flood defences over insurance are probably fairly small given that there is no profit to be made.
Finally, there exists an implicit state subsidy to your house being drowned, in that you can be confident that emergency services will come to rescue you and the cost is spread across the entire population. Putting flood defences in place would abolish this subsidy, and so the subsidy acts to reduce the private gain from putting up flood defences. There are several ways this could be fixed.
My preferred solution from reasons of both justice and efficiency, but one which would be politically impossible, is for the state to simply pull out of the business of rescuing people from flooding. Alternatively, the state could levy extra taxes on populations at risk of flooding, with the tax abolished if flood defences are put up. This would be less unpopular, but there might be problems in implementation - what, precisely, counts as sufficient flood defences for the tax to be lifted? Finally, the most politically feasible option: state subsidy for building of flood defences, up to the cost of rescue services. This third solution would represent a subsidy to the local population whether or not they put up flood defences, but at least it would sort out the misaligned incentives problem.
In any case, it is almost never going to be a good idea for central government to intervene. Apart from the standard problems with public goods interventions (see this and, indeed the post you are currently reading) there is a problem in economics traditionally illustrated using diners at a restaurant. If each pays his own bill, then each pays for what she/he believes will bring best value for money. If the bill is split between many of them, then since each now pays only a fraction of the price for his/her own bill, there is little incentive to keep the costs down. A man who would have bought himself a simple steak and chips with a Stella Artois to drink might well go for a full mixed grill with side salad and Peroni when most of the bill is paid by others. Similarly, if a centralised government - that is to say, the population of taxpayers at large - bears the cost of local projects (not just of flood defences, but also bridges, libraries, concert halls, etc) then we will end up with far more of these things than we need.
In conclusion, there is little to no reason why government should need to provide flood defences, and to the extent that there is this is as a result of previous mistaken government intervention.
See also: http://cafe-regence.blogspot.co.uk/2013/08/every-market-failure-is-business-idea.html