Swimmer's ear is caused by water removing the cerumen (wax) from the ear. This damages the lining of the canal and taking bacteria into the skin where it causes infection. The wax and squamous epithelium lining the canal usually protect the underlying dermis. It blocks bacteria such as Staphylococcus aureus and Streptococcus.
In the early stages the ears become sore and itchy. People often scratch them with a cotton bud or pen lid but this damages the skin further, worsening and prolonging infection. Don't!
Other causes include eczema and psoriasis. If you have skin condition underlying the problem seek help from a medical professional in order to treat the problem.
Prevention is through avoiding the risk factors. Keep out of the water, wash out your ears using water or alcohol and use swimming ear plugs to keep water from your ears.
Custom swimming ear plugs are much better than other types. This is because they are individually made for your ears so are comfortable and effective at keeping water out. ZenPlugs are exceptionally good. This is because they include an antibacterial which is proven to kill all the bacteria which cause ear infection.
Treat yourself to years of healthy ears with ZenPlugs Molded Swimming Ear Plugs from http://zenplugs.com.