I enjoyed this article in the Boston Globe which surveys a variety of theories for the (mostly anectodal) tendency for the most vocal moralizers to be the most prone to vice.  When you read an article like this you have to start with simple null hypothesis that, other things equal, making a person more concerned about moral behavior will make them inclined to act morally.  Many of the stories in this article are tempting, mostly because we want to hate hypocrites, but ultimately don’t put up a good counterargument to this benchmark view.  However the following excerpt is more subtle and in my opinion the most robust story offered.

When asked about the phenomenon of the hypocritical moralizer, psychologists will often point to “projection,” an idea inherited from Freud. What it means – and there is a large literature to back it up – is that if someone is fixated on a particular worry or goal, they assume that everyone else is driven by that same worry or goal. Someone who covets his neighbor’s wife, in other words, would tend, rightly or wrongly, to see wife-coveting as a widespread phenomenon, and if that person were a politician or preacher, he might spend a lot of his time spreading the word about the dangers of adultery.