In James 2:14, we read of one who says/claims he has faith but has no works. This is not genuine faith, but a bare profession of faith. So when James asks, "Can that faith save him?" he is saying nothing against genuine faith, but only against an empty profession of faith. James gives us the test for genuine faith: like the faith of Abraham, it results in producing works. James DOES NOT teach that we are saved "by" works. His concern is to show the reality of the faith professed by the individual (James 2:18) and demonstrate that the faith claimed (James 2:14) by the individual is genuine.
In James 2:21, notice closely that James does not say that Abraham's work of offering up Isaac resulted in God's accounting Abraham as righteous. No! The accounting of Abraham's faith as righteousness was made in Genesis 15:6, many years before his work of offering up Isaac recorded in Genesis 22. The work of Abraham did not have some kind of intrinsic merit to save his soul, but it proved or manifested the genuineness of his faith. This is the sense in which Abraham was justified by works.
In James 2:24, James is not using the word "justified" here to mean "accounted as righteous" but is "shown to be righteous." James is discussing the proof of faith (says-claims to have faith but has no works/I will show you my faith by my works), not the initial act of being accounted as righteous with God (Romans 4:2-3). Works bear out the justification that already came by faith.
Christ saves us through faith based on the merits of His finished work of redemption "alone" and not on the merits of our works. It is through faith "IN CHRIST" alone (and not by the merits of our works) that we are justified on account of Christ (Romans 3:24; 5:1); yet the faith that justifies is never alone (solitary, unfruitful, barren) if it is genuine saving faith in Christ (James 2:14-24). *Perfect Harmony.*