I think it could be explained by being an ... anti-Pauline writing ...
I think the letter James is clearly responding to Paul, but is not “anti-Pauline”. But rather, the letter attempts to put Paul in perspective, to correct misunderstandings of Paul’s teachings --- as did Paul himself.
The letter James stressed the need for both faith and good works. Paul did not come down on the side of faith over good works --- Paul only denied the need for circumcision and the Mosaic rituals for believers in his Jesus Christ.
Paul was a prude, and retained his conservative, Jewish sensibilities and sense of moral behavior. But it seems in his own time and in his own congregations some misinterpreted his “freedom from the law” and he found it necessary to set them straight, and not just from sexual immorality, but also theft, jealousy, drunkenness, and cheating ---
Or do you not know that the unrighteous will not inherit the kingdom of God? Do not be deceived; neither fornicators, nor idolaters, nor adulterers, nor effeminate, nor homosexuals, nor thieves, nor the covetous, nor drunkards, nor revilers, nor swindlers, will inherit the kingdom of God. (1 Corinthians 6:9-10, NASB)
Do not be deceived: "Bad company corrupts good morals." Become sober-minded as you ought, and stop sinning; for some have no knowledge of God. I speak this to your shame. (1 Corinthians 15:33-34, NASB)
The author of the letter James asked ---
What use is it, my brethren, if someone says he has faith but he has no works? Can that faith save him? (James 2:14, NASB)
I think Paul would have answered such a question with, “of course not”.
In Galatians, Paul was vehemently defending his position on circumcision and was in his finest “antinomian form”, yet he is still not always that far from what is found in James. But the comparison in the first box below is a bit of "apples and oranges", as circumcision is not addressed in the letter James ---
For whoever keeps the whole law and yet stumbles in one point, he has become guilty of all. For He who said, "Do not commit adultery," also said, "Do not commit murder." Now if you do not commit adultery, but do commit murder, you have become a transgressor of the law. (James 2:10, NASB)
And I testify again to every man who receives circumcision, that he is under obligation to keep the whole Law. (Galatians 5:3, NASB)
If, however, you are fulfilling the royal law according to the Scripture, "You shall love your neighbor as yourself," you are doing well. (James 2:8, NASB)
For in Christ Jesus neither circumcision nor uncircumcision means anything, but [only] faith working through love. (Galatians 5:6, NASB)
But now faith, hope, love, abide these three; but the greatest of these is love. (1 Corinthians 13:13, NASB)
Early collections of NT canonical texts are most often found in partial canon manuscripts, likely due to the cost and size of a more complete collection. The “Catholic Epistles” were almost always bound together with Acts. And the Acts + Catholic Epistles were much more commonly bound together with Paul’s letters than with the Gospels. I don’t think the early compilers of the canon saw the letter James as “anti-Pauline” either.