Stop believing human silliness and start acknowledging the truth.
IE Romans 3:23 for all have sinned and fall short of the glory of God
That includes Popes.
Basics.
This is not the place to argue it, but you are confused. Of course all men are sinners, but Jesus also said that Peter was the Rock on which He would found His Church, and also that He would be with His Church until the end of time, and that the Gates of Hell would not prevail against it.
As the annunciatory angels said to both Abraham and the father of John the Baptist, “With God, all things are possible.”
It is perfectly possible for God to prevent any pope from spreading heresy, even though a few popes were serious sinners.