"...when James and Cephas [Peter] and John, who were acknowledged pillars, recognized the grace that had been given to me, they gave to Barnabas and me the right hand of fellowship" - (2.9)clearly St. Paul who although he had been given a gift from God, also had to have it acknowledged by the Church.
"But when Cephas came to Antioch, I opposed him to his face, because he stood self-condemned; for until certain people came from James, he used to eat with the Gentiles. But after they came, he drew back and kept himself separate FOR FEAR of the circumcision faction. And the other Jews joined him in this hypocrisy, so that even Barnabas was led astray by their hypocrisy. But when I saw that they were not acting consistently with the truth of the gospel"- (2.11-14)
These are the key words. St. Peter was not TEACHING in contradiction with the gospel, but was acting in contradiction to it. And why? because of a temporary fear, he made a mistake (sin). Nowhere in Roman Catholic teaching does it say the popes will be sinless. Lest we forget that St. Paul was a murderer before his conversion, and struggled with the 'thorn in the flesh' for all his life.
"We ourselves are Jews by birth and not Gentile sinners; 16 yet we know that a person is justified* not by the works of the law but through faith in Jesus Christ.* And we have come to believe in Christ Jesus, so that we might be justified by faith in Christ,* and not by doing the works of the law, because no one will be justified by the works of the law." (2.15-16)
Now this is the 'nail in the coffin' of Catholic Justification in the view of many Protestants. However the great Protestant New Testament scholar and Bishop of the Church of England Dr. N.T. Wright reminds us that the phrase 'works of the law' means ceremonial jewish law observances, sacrifices, circumcision, etc. NOT good works. Furthermore I know nothing about Greek, and only know a little latin, and the question could be answered if 'faith' in verse 16 is in the Genetive/Possessive or another case. BUT my NRSV study notes say that an alternative reading can be "we might be justified by the faith of Jesus Christ" ie. Christ's obedience to God's will. NOT a personal faith in him apart from good works. This phrase 'faith in Jesus' or 'faith of Jesus' appears also in Gal 2:20, 3:22; Rom 3:22, 26; Phil 3:9, and the scholars in my NRSV commentary say that this phrase emphasizes Jesus' faithfulness and obedience to God on the cross.
In Short, nowhere does Roman Catholic theology say that Popes are not allowed to make mistakes, or to act in contradiction to the gospel. Once again Galatians 2 has been used to contradict a twisted version of papal infallibility.