My understanding is that the Pope is infallible when speaking ex cathedra on matters of Faith and Morals because the Holy Spirit will preserve the Church from error. I also believe the Pope has only used infallibility twice and I think one of them was in the 50s and was related to Mary’s Assumption.