12 For before certain men came from James, he used to eat with the Gentiles. But when they arrived, he began to draw back and separate himself, for fear of those in the circumcision group. -Galatians 2:12 BSB
The hypocrisy of Peter was seen in this way: Jews wouldn’t associate with Gentiles, visit their homes, or sit down to have a meal with them. The reason is that the Jews didn’t want to participate with the Gentiles in any form and fall into their pagan beliefs or practices (see Deuteronomy 7:3-4 below). However, Peter understood if a Gentile and Jew have put their faith in Jesus Christ, they are one in the Lord and are brothers in Christ.
3 Do not intermarry with them. Do not give your daughters to their sons or take their daughters for your sons, 4 because they will turn your sons away from following Me to serve other gods. Then the anger of the LORD will burn against you, and He will swiftly destroy you. -Deuteronomy 7:3-4 BSB
When James came accompanied by Jews, Peter felt fear that he would get caught eating with the Gentiles, so he removed himself from them, showing his hypocrisy because before James and the other Jews came, Peter had no problem eating with them.