Corruption's comparatively rare these days, but it's a database as you said, and stuff happens. It's usually down to hardware issues - power outages, computer crashing, kernel panics, external hard drive getting disconnected while LR's trying to write to the file, that kind of thing.
Preventative measures - just be sensible. Keep good incremental backups such as LR's own backup rather than just overwriting the previous backup. Don't disconnect external hard drives with LR open. If possible, keep the catalog itself on an internal drive, so that you don't accidentally disconnect it.
Remedies - the repair tool does a pretty good job, but it can't fix everything, so backups are essential. Sometimes simply copying the catalog to a new location can do the trick, if it's not actually corrupted but giving a false warning. And in many cases, the corruption is limited to a small area of the catalog - in those cases, if there aren't any backups and the corruption's not too severe, creating a new catalog and using Import from Catalog to pull data over a small chunk at a time can rescue most of the data, but it takes a bit of trial and error to find the corrupted chunk, but it can save the day on occasion.