I am Catholic and I do read the Bible that’s how I know you can’t compare Luther to King David.
King David sinned but was always sorrowful and repentant. Luther was neither.
And as a disclaimer, I wouldn’t compare our new Pope to King David either. Personally I think he’s a heretic. But the Church doesn’t belong to this Pope or any other. It belongs to Christ, the creator of it.
You have no idea whether he was or was not repentant.
The point remains, God continues to use flawed people.