Why do people use sandbags before a flood?

It's common to see homes barricaded with sandbags in anticipation of severe flooding. Why are sandbags used and what makes them so effective?