The word for righteous is “dikaios”, meaning:
1) righteous, observing divine laws
a) in a wide sense, upright, righteous, virtuous, keeping the commands of God
1) of those who seem to themselves to be righteous, who pride themselves to be righteous, who pride themselves in their virtues, whether real or imagined
2) innocent, faultless, guiltless
3) used of him whose way of thinking, feeling, and acting is wholly conformed to the will of God, and who therefore needs no rectification in the heart or life
a) only Christ truly
4) approved of or acceptable of God
b) in a narrower sense, rendering to each his due and that in a judicial sense, passing just judgment on others, whether expressed in words or shown by the manner of dealing with them
James is obviously using it in sense 1A - a good person. And no one denies there are people who are better than others at doing good.
However, Paul is obviously using it in sense 3, for the preceding sentence is “We have already made the charge that Jews and Gentiles alike are all under sin.”
I quoted just that verse, but the one prior also makes the case - that ALL ARE UNDER SIN.
In chapter 1, Paul talks about the righteous judgment of God on evil men. In chapter 2, he essentially says, “You felt good while I was condemning homosexuals, but your own words and thoughts condemn you, for you are just as bad in the eyes of God.” Chapter 2 finishes with a reply to those who say, “I’m a Jew, I have the Law of God...”
Chapter 3 starts off by saying, yes, the Jews have much to boast about - BUT NOT SINLESS, since righteousness comes from faith, not obeying the law. And then Paul says, “9 What shall we conclude then? Are we [Jews] any better? Not at all! We have already made the charge that Jews and Gentiles alike are all under sin. 10 As it is written:
“There is no one righteous, not even one;
11there is no one who understands,
no one who seeks God.”
So Paul’s meaning here does not contradict James, but it does contradict the claim that Mary was without sin, and obeyed the Law her entire life.
Babies are probably born tainted by sin. I say probably, because I haven’t researched the Scripture enough to feel confident of my answer. However, a 2 year old most definitely shows all the signs of sin in his/her life!
And yes, John the Baptist sinned. Matthew 11 records his doubt about Jesus.
If someone can live without sin, why did Jesus need to die? “21 I do not nullify the grace of God, for if righteousness were through the law, then Christ died for no purpose.”