“The Holy Spirit prevents Supreme Pontiff from teaching error in faith and morals.”
You forgot the most important part: the above is true only when the pope speaks “ex cathedra”.
See post 32, ex cathedra is implied.