As the unblemished Bride of Christ, the Church is perfect in Her nature:
In the case of the Church, the whole is not equal to the sum of its parts - in fact, the whole is infinitely greater than the sum of its parts (meaning us sinners, and even wretched sinners, who grow alongside the good wheat until the harvest time).
The Church is not perfect because of Her sinful members, but because of the perfection of Her Founder and Groom.
The Church is perfect, although only a few of Her members have achieved spiritual perfection while on earth.
(for those who wish to blindly jump in and challenge the notion that anyone can achieve spiritual perfection on earth, I refer you to three Doctors of the Church who maintain otherwise (and were named Doctors for this teaching) - St. Thersa of Avila, St. John of the Cross, and St. Therese of the Child Jesus. If you wish to challenge these Doctors, please open a new thread so this thread may remain on-topic)