That is correct because these books contradicted his own doctrine. He wanted all books taken out of the Bible which did that.
It’s a bit more nuanced than that. Jerome had also noted that that Hebrews and James were less-apparently apostolic than, say, the letters of Paul - he accepted them because he was obedient to the Authority of the Church, not because he was intellectually convinced. Luther rejected the authority of the Church and because of that, was reduced to deciding for himself which books were inspired.
There were, as most people here know, many books that were discussed in the early days of the Church - only a few that every accepted without question, many more that some people accepted and others did not. We all remember Hebrew and James because Luther re-activated that conversation, but many are not aware, for example, that all of the writings of John were disputed and there were many who rejected his gospel, particularly.
It is not accurate to say
Rome accepted some books as Scripture and then later rejected them.
What books were “accepted by Rome” and later rejected? Do you mean the local Church at Rome, or do you mean the Universal Church?
The Shepherd of Hermas, the letters of Clement - there were lots of legitimate, authentic writings that were not included in the final canon but were read in some regional churches in the early years. These, like John’s writings and Hebrews and John, were the subject of discourse and debate. There were also books like the Gospel of Thomas that were integral to the early heresies and so relatively simple to reject.
The question of canonicity doesn’t even begin until Marcion (mid-second century), and by the time Anathasius writes his list (367) it is apparently settled. Two hundred years in a time when both communication and travel were time-consuming and laborious is really not very long. And the list of canonical books was surely not as urgent a question as the Christology questions being sorted out and defined in the same period. (It was, don’t forget, just a list of books that would be allowed for liturgical use, that would be proclaimed as “the Word of the Lord.” No one was suggesting that once the canon was established it would become the only source of legitimate teaching. THAT was Luther’s heresy.)
In response to the OP, we believe that the Church’s decision-making process and ultimate declaration of the canon is reliable because we accept Jesus’ statement that He will send the Holy Spirit to instruct the Apostles (and, we believe, their successors) and protect them from teaching error. Unlike Luther, we do not need to figure this out for ourselves and in our own intellects. And unlike Luther, we do not believe that the canonical Scripture is the only manifestation of God’s teaching we can rely upon.