It is an often repeated mistake for Bible readers to assume that “the works of the Law” means any good work or act of obedience to God.
However, Paul appears to mean by this term in his first century context “the externalities of the Mosaic Law”. If someone said, “You have to be circumcised to be saved, and obey Old Covenant separation laws, feast days and dietary restrictions” he would be talking about what hopeful Gentile converts in the first century were being warned to avoid. This is consistently the subject matter brought up by Paul when he addresses the issue. Gentiles had known similar strictures in their pagan religions and should not return to such a bondage by adopting the Mosaic system.
Paul stated that circumcision means nothing on its own, but if it is enjoined as a means of being justified before God, coupled with a belief in Jesus, then the confused religionist has fallen decisively out of the sphere of grace. He reveals a false and distorted belief that Paul anathematizes. Clearly Paul’s emphasis and argument was on avoiding externalities of religion as a means of obtaining acceptance before God. Such a system, coupled with some view of faith in Christ, damns.