Peter ate with the non-Jewish believers because God had shown him it was right (Acts 10:9–16, 34–35).
James's friends wanted to stop Jewish and non-Jewish believers from eating and meeting together freely. These people insisted that everyone should follow strict Jewish religious customs. They tried to force non-Jewish believers to follow Jewish rules about food and religious practices.
he used to eat with the Gentiles. But when they arrived, he began to draw back and separate himself: When Peter refused to share meals and the Lord’s Supper (see 1 Corinthians 11:20–22, 33–34) with fellow Christians, he created a divide between Jewish and Gentile (non-Jewish) Christians. This suggested that Jewish customs made them more acceptable to God. If not uncorrected, Peter’s actions would have weakened the message of salvation by grace through faith.
for fear of those in the circumcision group: James's friends pressured Peter so much that he became afraid. This was surprising because earlier, when people criticized Peter for the same thing, he had stood up to them bravely and spoke strong words to defend his actions (Acts 11:2–18).
Peter might have had two reasons for his actions. First, he might have worried that his actions would make it harder for Jewish people to accept Jesus. Second, he might have been worried about the safety of Jewish Christians in Judea, who were being treated badly by non-Christian Jews (compare 5:11; 6:12). But even if Peter had good reasons, what he did was still wrong.