Both passages you ask about, from Ephesians 2 and Romans 6, were written by the apostle Paul. The passages from James were both written by James, the brother of Jesus. Please note that I am using an ESV translation of the Bible for any quotes.
At first glance, Paul seems to emphasize that Christians are made right with God through their faith alone, not by any good works they have done. In Ephesians 2:8-9, Paul makes this clear:
For by grace you have been save through faith. And this is not your own doing; it is the gift of God, not a result of works, so that no one may boast.
In contrast, James seems to argue that works are needed to be made right with God. In James 2:24, James writes:
You see that a person is justified by works and not by faith alone.
While Paul and James seem to contradict, they are presenting compatible teachings. In Romans 6:1-4, Paul makes this clear. He scoffs at people who continue to sin, “that grace may abound.” In other words, he disdains people who are sinning because they know they can just be forgiven by the grace of God. This kind of lifestyle cheapens the gift of grace. Instead, the baptism of Christians symbolizes the death of Christ. As a reflection of the physical death of Christ, Christians are to “die” to their selfish and sinful desires. Reflecting the resurrection of Christ, Christians are meant to be raised from the waters of baptism and begin a new lifestyle of following God. Paul writes that “just as Christ was raised from the dead by the glory of the Father, we too might walk in newness of life” (Romans 6:4).
In Ephesians 2, Paul is clear that salvation is through grace, not works. Yet this new life in Christ is for the purpose of good works. Paul writes to his Christian audience that they are “created in Christ Jesus for good works … that we should walk in them” (Ephesians 2: 10). As Christians—literally, Christ-followers—they should naturally want to walk in the good works of God, rather than their own selfish pursuits.
This is why James writes with confidence that “faith by itself. . .is dead” (James 2:14). If a person has truly been converted and baptized into Christianity, this inner change should be demonstrated in their works. This is why James questions the authenticity of someone who claims to have faith, but does not perform any good deeds. He especially criticizes those without concern for the poor (James 2:15, James 1:27). This “faith alone” argument, according to James, is really an example of false faith.