The Romans Passage
In Romans 1, Paul showed the basic tension that would underline the whole letter in verse 16; he said the gospel is the power to salvation for the Jew as well as the Greek. He continues to explain that righteousness is revealed in it it a way that emphasizes faith.
His long explanation that follows points out that God's wrath is revealed to be against people who, like the barbarians, fight against what can be known about God and his truth by their chasing after unrighteousness.
Not only is God's wrath against those who do these things, he says, but also against those who, after knowing about the punishment that is decreed to fall, determine that those who practise such things are right.
If chapter one seemed to address the sinfulness of the barbarians, chapter two seems to address those who believe themselves to be religious.
You, therefore, have no excuse, you who pass judgment on someone else, for at whatever point you judge another, you are condemning yourself, because you who pass judgment do the same things!
Now we know that God’s judgment against those who do such things is based on truth. So when you, a mere human being, pass judgment on them and yet do the same things, do you think you will escape God’s judgment? Or do you show contempt for the riches of his kindness, forbearance and patience, not realizing that God’s kindness is intended to lead you to repentance?
But because of your stubbornness and your unrepentant heart, you are storing up wrath against yourself for the day of God’s wrath, when his righteous judgment will be revealed. God will repay each person according to what they have done.
His point is that judgment will fall, not on specific ethnic groups, but on all people. The same standard will fall on everyone: righteousness (defining this word/concept is beyond the scope of the question).
As verse 11 points out in the context of judgment, "God does not show favoritism."
Verses 12-16 discuss some specifics on how the coming judgment will take place, and verses 17-24 contain a rather pointed cross-examining of the current Jewish mindset. It is concluded in the scriptural accusation, "God’s name is blasphemed among the Gentiles because of you."
He then points to their biggest sign of their right to Abraham's covenant: circumcision. His thoughts on their right to inherit the promise based on their obedience to this one prime condition of Jewishness can be summarized as verse 25.
Romans 2:25 - Circumcision has value if you observe the law, but if you break the law, you have become as though you had not been circumcised.
His point being that being a Jew is not simply the same as being circumcised. What makes a Jew a Jew is his obedience to the Law, and that brings us to Chapter 3, and to the verse in question.
What advantage, then, is there in being a Jew, or what value is there in circumcision? Much in every way! First of all, the Jews have been entrusted with the very words of God.
Looked at in this light (are Jews closer to God than Gentiles?), this incongruity seems to resolve itself.
The value of circumcision, even of being a Jew, has just been called into question, since that supreme identifying act of Abraham's covenant didn't automatically make a person more righteous in God's eyes. So why was it so important to be a Jew in the first place, if both Jews and Gentiles fall under similar judgments?
Paul's answer was that the importance of being a Jew lay in the fact that it was the Jews that were entrusted with the words of God. Even though that sounds like circumcision gave them some kind of advantage, he later (in verses 9-18) will point out that being a Jew still didn't break the power of sin. He will move on from that point to their following of the Law to the same effect.
Jews and Gentiles alike stand in judgment - there is no advantage in circumcision, apart from being (among other things) God's Law-bearers.
The Galatians Passage
I'm not going to be so verbose on this passage - just enough to show the difference. Remember, though (or refer to Galatians 1:6 and surrounding context), that this is a letter written to believers who are considering turning aside to a perversion of the gospel they were taught.
The verse in question, Galatians 5:2
Listen! I, Paul, am telling you that if you let yourselves be circumcised, Christ will be of no benefit to you.
Notice immediately that this is referring to a decision that the readers could do theoretically, some action they could make in the present or future. He is not speaking of the benefits of having been circumcised, or whether it was important for circumcision to even have existed. This is specifically speaking of a weighty decision to become circumcised.
Why, then, was the law given at all? It was added because of transgressions until the Seed to whom the promise referred had come. The law was given through angels and entrusted to a mediator. A mediator, however, implies more than one party; but God is one.
Is the law, therefore, opposed to the promises of God? Absolutely not! For if a law had been given that could impart life, then righteousness would certainly have come by the law. But Scripture has locked up everything under the control of sin, so that what was promised, being given through faith in Jesus Christ, might be given to those who believe.
Before the coming of this faith, we were held in custody under the law, locked up until the faith that was to come would be revealed. So the law was our guardian until Christ came that we might be justified by faith. Now that this faith has come, we are no longer under a guardian.
In this passage which came a little ways before the text in question, we can sense the direction of his reasoning. He had been speaking of the covenant that God had made with Abraham, and showed that the law that followed did not set aside their covenant. The covenant plainly does not depend on their obedience.
Our quoted passage intervenes at this point to wonder what the purpose of the Law was, if not to adapt the promise given to Abraham. His answer says that the Law was a guardian to lead people to Christ. Faith in Christ has come, so the guardian is not necessary anymore.
But notice how he ties all that up.
So in Christ Jesus you are all children of God through faith, for all of you who were baptized into Christ have clothed yourselves with Christ. There is neither Jew nor Gentile, neither slave nor free, nor is there male and female, for you are all one in Christ Jesus. If you belong to Christ, then you are Abraham’s seed, and heirs according to the promise.
His previous arguments have set aside the Law as being attached to the inheritance promised to Abraham, but in this passage, he attaches the promise directly to those who are in Christ.
He will follow these arguments with various explanations and proofs, but this passage is enough to explain his focus in the verse in question.
If you get circumcised now, he is telling them, leaving what you've learned about Christ to dive into Abraham's covenant through circumcision, Christ is simply not going to profit you in any way!
Again I declare to every man who lets himself be circumcised that he is obligated to obey the whole law. You who are trying to be justified by the law have been alienated from Christ; you have fallen away from grace. For through the Spirit we eagerly await by faith the righteousness for which we hope. For in Christ Jesus neither circumcision nor uncircumcision has any value. The only thing that counts is faith expressing itself through love.
Is there a contradiction between Romans 3:1-2 and Galatians 5:2?
It would seem like Paul is for circumcision in Romans, but makes a u-turn in Galatians, where he seems to preach against circumcision.
There does not appear to be any shift in Paul's opinion on circumcision in these passages.
In the first passage, context upholds that Paul places no value on circumcision's ability to excuse them in any way when God judges the world. The only value that he attributes to circumcision in the case of Romans 3:1-2 is that it was through the circumcised that God's word came. Circumcision had a value, but it does not appear to be a value important to those currently in Christ.
In the second passage, He says plainly that circumcision has no value to those currently in Christ - in fact, to get circumcised is essentially the same in his eyes as pledging to follow the Law of Moses! Since he sees this Law as a guardian to bring us to Christ, and since justification cannot occur through it, Paul highly frowns on this, seeing this as equivalent to falling from grace.
In both verses, Paul sees circumcision as having no current value important to a disciple of Christ.