Once you start to look at the gospels one by one, you realize that followers of Jesus were trying to understand what had happened after he was arrested and killed. They knew Judas had handed him over to the people who arrested him.
Although the gospels of the New Testament-- like those discovered at Nag Hammadi-- are attributed to Jesus' followers, no one knows who actually wrote any of them.