Paul introduces these ideas in Galatians 2:4. He uses the metaphor of slavery for people who are obligated to obey the law of Moses. He uses the metaphor of freedom, or liberty, for people who are not obligated to obey the law of Moses because they trust in Jesus Christ to make them righteous.
When Paul says that false brothers wanted to make the believers slaves, he is referring to Jews who claimed to be Christians and who wanted to convince Gentile Christians to obey the law of Moses.
Jews normally did not eat with Gentiles because Gentiles did not obey the law of Moses. Cephas knew that Gentile Christians are not obligated to obey the law of Moses, and because of this, he knew that it was permissible to eat with them. However, when some men came saying that Gentile Christians are obligated to obey the law, Cephas stopped eating with the Gentiles Christians, as if he, too, believed that they need to obey the law of Moses. Paul rebuked Cephas for treating the Gentile Christians like that.