The central thesis of Romans can be found in Romans 1:16-17,
"For I am not ashamed of the Gospel for it is the power of God to save all who believe, the Jew first and also the Greek; for by it the justice of God is revealed from faith to faith, as it is written, 'The just shall live by faith.'"
An underlying context for the Epistle to the Romans is that Paul is writing to a mixed community of believers: Jews and Gentiles. So, for example, when Paul says, "All have sinned and fallen short of the glory of God." (Romans 3:23) that "all" here means "Jews and Gentiles", it means everyone, but in context it means everyone, both Jews and Gentiles. The sinfulness of the Gentiles which is "obvious" in their Paganism (see Romans 1:18-32) is no more sinful than the sinfulness of the Jews, being Jewish and knowing God's Law does not render one any less sinful, and indeed if one imagines they are more righteous they are merely a judgmental hypocrite (Romans 2:1-5).
So the Law, in its righteous pronouncement, declares that all are condemned as sinners, both Jew and Gentile.
So let's look at the passage in Romans 2 mentioned by the OP:
"For all who have sinned without the Law will also perish without the Law, and all who have sinned under the Law will be judged by the Law. For it is not the hearers of the Law who are just before God, but the doers of the Law who will be justified. For when Gentiles, who do not have the Law, by nature do what the Law requires, they are a law unto themselves, even though they do not have the law. They show that the work of the Law is written on their hearts, while their conscience also bears witness, and their conflicting thoughts accuse or even excuse them on that day, when, according to my gospel, God judges the secrets of men by Christ Jesus.
But if you call yourself a Jew and rely on the Law and boast in God and know His will and approve what is excellent, because you are instructed in the Law; and if you are sure that you yourself are a guide to the blind, a light to those who are in darkness, an instructor of the foolish, a teacher of children, having in the Law the embodiment of knowledge and truth--you then who teach others, do you not teach yourself? While you preach against stealing, do you steal? You who say that one must not commit adultery, do you commit adultery? Who you abhor idols, do you rob temples? You who boast in the Law dishonor God by breaking the Law. For, as it is written, 'The name of God is blasphemed among the Gentiles because of you.'
For circumcision indeed is of value if you obey the Law, but if you break the Law, your circumcision becomes uncircumcision. So, if a man who is uncircumcised keeps the precepts of the Law, will not his uncircumcision be regarded as circumcision? Then he who is physically uncircumcised but keeps the Law will condemn you who have the written code and circumcision but break the Law. For no one is a Jew who is merely one outwardly, nor is circumcision outward and physical. But a Jew is one inwardly and circumcision a matter of the heart, by the Spirit, not by the letter. His praise is not from man but from God." - Romans 2:12-29
Really soak all this in.
None of this is about how we can, by obeying the Law, become righteous before God. This is not, we would say, "How to get saved" language; this is, "Here is how you are condemned" language. This is about how one who thinks they are righteous because they have the Law and have learned the Law (aka Jews in context here) do not have a leg to stand on in righteous against their Gentile neighbors; because--for example--a Pagan Gentile who does not steal shows that they are closer to the Law than a Jewish person who steals. So simply knowing the Law--being a hearer of the Law, one who has been instructed and taught in the precepts of Torah--does not reckon one righteous--God actually says to do that which is just and righteous, not merely to know what is just and righteous. Knowing that it is wrong to steal does not make one righteous if one is stealing; you're actually supposed to not steal.
To properly understand where Paul is taking this line of thinking we have to continue into chapter 3. I am going to highlight a specific portion of Romans 3, but please do start from verse 1 of the chapter and go onward,
"Now we know that whatever the Law says it speaks to those who are under the Law, so that every mouth may be stopped, and the whole world may be held accountable to God. For by works of the Law no human being will be justified in His sight, since through the Law comes knowledge of sin.
But now the justice of God has been manifested apart from the Law, although the Law and the Prophets bear witness to it--the justice of God through faith in Jesus Christ for all who trust. For there is no distinction: for all have sinned and fall short of the glory of God, and are justified by His grace as a gift, through the redemption that is in Christ Jesus, whom God put forward as atonement by His blood to be received by faith. This was to show God's justice, because in His divine forbearance He had passed over former sins. It was to show His justice at the present time, so that He might be just and the justifier of the one who trusts in Jesus." - Romans 3:19-26
What Paul had been talking about was universal condemnation by the Law. The Law condemns both Jew and Gentile; so that no one is with excuse; knowing the Law does not justify one because knowledge of the Law only means that our disobedience to the Law condemns us as sinners; and not knowing the Law does not justify one because we still have conscience which condemns us for our lawlessness and sin. So that both the Jew and the Gentile stand accused as guilty, therefore all have sinned and fallen short; or as Paul had said earlier in this chapter, "There is no one who is just, not even one".
But even all have sinned and are condemned; so all who trust in the Messiah Jesus are justified, for Christ is the atonement who reconciles us to God, that through faith in Him we regarded just; not by what we have done; but by faith--out of the compassion and grace of God, not of our glory and self-assuredness.
From here onward Paul continues to speak of justification, in Romans 4 he will go back to Abraham and how Abraham "had faith and it was reckoned to him as justice", and also continuing into Romans 5. Though Paul will turn his attention at the end of Romans 5 and into Romans 6 about how God's grace, and our faith, does not permit us to merely sit on our laurels and think, "Since grace abounds, I can go on sinning", which Paul condemns. But this is for another conversation.
Here Paul is telling his audience in the Church in Rome, both Jew and Greek alike, that all stand condemned equally. The "doer of the Law" being justified is not said in isolation, it is in the context of everything Paul is talking about--we must understand the context and the thesis of Romans. The Gospel universally saves (that is, it saves all who believe, whether Jew or Gentile) because all are universally condemned already because of sin, both Jew and Gentile alike without distinction.
Romans is such a breathtakingly brilliant work, we should take the time to really dig into it--because simply taking it piecemeal really deprives one of the rich banquet of the epistle.
-CryptoLutheran