Papal infallibility does not mean that every word that comes out of his mouth is true. It means that he can not bind the faithful to believe error. So when he officially exercises his power and declares that something must be believed by all the faithful then he will be divinely protected from teaching error.