Justification by faith was based on the model of all of humanity being sinners who deserve eternal damnation, but Christ made a payment which resulted in Him bearing our sins instead of us, and by faith we could accept the payment and have his righteousness imputed to us.
Salvation is therefore by faith alone without any works on our part.
In this model salvation is also by faith alone without any works or merit on our part. And that is exactly what James is saying. And this is the opposite of trying to make ourselves right by our own works, which was the Galatian heresy.