The Church was not wrong.  The Church decided Jesus admonitions about protecting the flock were no longer as important as protecting the Institution.  Canon Law, mandated by the infallible Saint Pope.  Regarding moral authority, Jesus Christ Himself gave the Pope the moral authority and the Pope decided it was moral to protect the Church, so there is no need to discuss punishing the men chosen by the Holy Spirit to lead the Church.  Your analysis implies that the Pope can be held to a moral standard by others,  That is wrong.  He sets the standards.