These are generally called Mats. They are particularly a problem with long haired cats, but short haired cats can get them too. They are more susceptible to them in the spring and fall when they are shedding their seasonal coats. Also, overweight cats might get them in parts they can't easily reach to groom (i.e. their back).
Prevention is quite simple, just brush your cat regularly and they are unlikely to occur. The main goal is to facilitate shedding. I'd recommend a strong wire brush (often called a cat rake) for this, for example something like:
The reason for this sort of brush is that it gets into their undercoat where mats generally develop. So when brushing your cat with this you want to be fairly aggressive (which they tend to like). The other advantages of regular brushing are that your cat will most likely love it, they will shed less (if your cat is indoors), santization (brushing out dirt / cat litter) and it will help prevent hairballs as well.
As far as what causes them I am not entirely sure, but I think it is probably similar to "Why do cords always end up getting tangled?"