It is no great secret that a certain types of personalities tends to gravitate towards power and influence. Whether it is status, wealth or outright malevolence, these people will go where the power is. Today, we know where the power is and it isn’t in religious institutions though there are still some scraps to be fought over in that realm. In the past, the Church did hold a lot more power and so attracted power-seekers along with the genuinely pious. Our Lord Jesus Christ knew this and warned his followers about it a number of times.
When Christianity was dominant, anyone who sought power of any kind had to do so within the church as it was and had to at least appear to accept the tenets of the faith. Nowadays, that is not necessary but the people that point to the corruption in the church as reasons for it being “bad” are generally speaking, the same type of people who caused all the corruption in the past. The same is true for the actions of governments of all stripes too.