Are popes all good teachers? No. Are all popes wise? No. Are they all good men? No. Are all their commands legitimate? No. Is the Holy Spirit behind every act of every pope? No. Is he behind everything popes say? No.
You, like a lot of other people on this site, don't have a proper understanding of the limits of papal authority. It is limited from above. No pope may counter the Divine Law or order that which would injure souls or harm the Church in any way. If he does, such commands would be nullities.
You also should remember that not all churchmen who seem good, and holy, and pious, are the real thing. We only see and know what those in power wish us to see and know. Our knowledge is limited. We must use other means to understand what's happening. Our Lord gave good advice. He said a good tree bears good fruit and a bad tree bears bad fruit. He said by their fruits we would be able to distinguish whether a man were a false prophet or a true one. Some would look like sheep, but would be wolves under sheep's clothing. Some would be the real thing. We had to judge by their fruits--and the fruits of this pontificate have been corruption and apostasy. That's clear to me.
So yes, some popes are not blessed by Heaven. Some go off on tangents of their own, paying little heed to the truths passed-down to them. When they do this, they should not be followed.
Lefebvre being Exhibit A.