From what I understand, the most common cause is bacteria entering the teat due to not cleaning the udder well, a dirty pen, not dipping teats, loose orifices, and sometimes bacteria just manages to get in no matter what you do. It is debatable wether leaving a doe unmilked for a long period of time a can be a cause. I try to stick to 12 hour apart milkings. I am sure there are other causes and certain diseases that make them more prone to mastitis.
My first experience with mastitis is when I bought a heavy milking doe who I didn't realize already had it. Her udder was leaking, even though we were very strict about milking her every 12 hours. We had to cut out her grain to make it stop. I believe that is how the bacteria got in, it would make sense. It can also spread through staph. There are many kinds of mastitis. Most cases actually go undetected and clear out -- those are minor cases. There are forms that are staph related, which are usually less serious and can be whipped with a little persistence.
Mastitis can also be spread from one affected doe to the other through shared milk pumps, udder creams, and (rarely) bedding.