"Justified" has the same meaning in each verse. You have to look at those verses in the larger context to understand what the authors are referring to by "works" and how that relates to justification.
James 2:14-26 makes the point that true faith always leads to works. The clearest statements are in verses 17 and 26:
17 Even so faith, if it has no works, is dead, being by itself.
26 For just as the body without the spirit is dead, so also faith without works is dead.
The key phrase in verse 24 is "not by faith alone". James is not saying that there are works that will justify you, he is saying that good works are the proof of the faith that justifies.
Paul is working from a slightly different angle. He makes the point in Romans 3:21-31 that obeying the Old Testament Law is not the path to righteousness.
21 But now apart from the Law the righteousness of God has been manifested, ... 22 even the righteousness of God through faith in Jesus Christ for all those who believe;
No one (aside from Jesus) has followed the Law to the point that they are considered by God to be righteous. The only effective path to justification and righteousness available to mankind is faith in Jesus. Verse 28 contrasts justification by faith (which is available to us) and justification by obeying the Old Testament Law (at which all of mankind has failed).