Now the centurion, and those who were with him keeping guard over Jesus, when they saw the earthquake and the things that were happening, became very frightened and said, "Truly this was the Son of God!" (Matthew 27:54)Now when the centurion saw what had happened, he began praising God, saying, "Certainly this man was righteous." (Luke 23:47)
We see that "the Son of God" (Matt 27:54) "was righteous" (Luke 23:47). This is to be distinguished from mortal men, among whom "there is none righteous, not even one" (Rom 3:10).However, through Belief in Jesus as Christ, righteousness is imputed to all who Believe (Rom 3:22).There is no contradiction here, rather these two passages fruitfully teach us correct doctrine.