Well, the general rule I *wish* the government followed would be “do as little as necessary.”
That said, there are certain types of things that justify government involvement:
- Milton Friedman used to talk about “neighborhood effects” being a justifiable reason for regulation. For example, there is no free market pressure on a polluter to stop polluting, and the consequences of their polluting can be dire. So, this justifies some types of regulations.
- BIG Stuff. National defense, space programs, interstate flood control projects, infrastructure…..
- Things with positive ROI for the government. So, you can justify programs that help poor kids get through community college, because the added taxes the kid will pay over their lifetime more than breaks even.
On the particular issue you raise of flooding, the government causes most of the trouble rather than solving it. There exists a national flood insurance program which provides coastline and floodzone homeowners with affordable insurance; if not for this program, the cost of insurance for those areas would be prohibitively high, and they would not build there. So, the government is an enabler of bad behavior by covering the potential losses with taxpayer subsidized insurance (moral hazard).