Because he was talking about being circumcised IN ORDER TO BE JUSTIFIED BY THE LAW.
The prohibition against the law is keeping the law IN ORDER TO BE JUSTIFIED, not against keeping the law.
We don't know this because we have been taught that Paul said keeping the law is what you must not do. Which is quite ridiculous when you see that he himself kept the law.
Acts 16:1-3, “1 Paul came also to Derbe and to Lystra. And a disciple was there, named Timothy, the son of a Jewish woman who was a believer, but his father was a Greek, 2 and he was well spoken of by the brethren who were in Lystra and Iconium. 3 Paul wanted this man to go with him; and he took him and circumcised him because of the Jews who were in those parts, for they all knew that his father was a Greek.”
Galatians 5:2, Mark my words! I, Paul, tell you that if you let yourselves be circumcised, Christ will be of no value to you at all.”
Acts 24:14, "But I confess this to you, that after the way which they call heresy, so I (Paul) worship the Father of my fathers, believing all things which are written in the Law and in the Prophets."
Romans 7:25, "Thanks be to YHWH, I have deliverance through Yahshua Messiah our King! So then, with this same mind, I myself serve the Law of YHWH, while in the flesh that is yet subject to the law of sin."
Acts 21:24, "Take them, and be purified with them, and pay their expenses so that they may shave their heads. Then everyone will know that those things they were informed about you (forsaking the Law), were lies, and that you (Paul), yourself, walk orderly, and keep the Law."