James 2 vs doctrine of justification by faith

On the surface, there seems to be two seemingly contradictory ideas between: 1/ James and his faith proved by action in James 2, and, 2/ Luther’s doctrine of justification that we cannot be saved by our good works.  I’ve heard Christians present James as a counter-argument to the doctrine of justification by faith.

The Reformational teaching of justification by grace thru faith says that we cannot be saved by our good works because we are all imperfect sinners at heart.  Our works will never be good enough for God. We can only be saved through our faith in Jesus.  The Apostle Paul taught, “For we maintain that a man is justified by faith apart from works of the Law” (Romans 3:28). Ditto in Rom. 4:5; 11:6; Gal. 2:16, 3:5-6; Eph. 2:8-9; Phil. 3:9, plus many more.

James 2:20-24 seems to juxtapose an alternate view of faith and action:
“20 You foolish person, do you want evidence that faith without deeds is useless? 21 Was not our father Abraham considered righteous for what he did when he offered his son Isaac on the altar? 22 You see that his faith and his actions were working together, and his faith was made complete by what he did. 23 And the scripture was fulfilled that says, “Abraham believed God, and it was credited to him as righteousness,” and he was called God’s friend. 24 You see that a person is considered righteous by what they do and not by faith alone.”

These are two different ideas.  There is no contradiction here but it seems so easy to confuse these two ideas.