The same thing happened within the American Psychiatric Association with regards to the classification of homosexuality in the DSM as a form of deviancy and therefore as a pathology. All the while, many members were themselves gay and formed some small union of activist types who sought to slowly upend the codifications from within. It’s a glacial and bureaucratic process, but they succeeded. At the same time, many of them practiced psychiatry, and I don’t doubt found meaning in their practice to help people for other issues. The DSM isn’t all bad even if it’s flawed.
Now, imagine doing it for a dogmatic scripture held dearly by many millions. Sure, the Catholic Church is on the wrong side of history when it comes to gay rights, among other things, but if some people find peace and meaning in its voluminous scriptures, then there is still a leadership role for those priests. That might explain the cognitive dissonance.