Certain material was judged to be inappropriate for the general congregation. Thus only the four gospels were included in the canon and not the gospels of Peter, Mary, Thomas, Philip or Judas. Given the brutal Roman persecution of the early Christians, a gospel that did not relate to the people's suffering was rejected. For example, Peter's gospel asserted that Jesus never really suffered - he was considered wholly divine. So although Peter was close to Jesus, his gospel was rejected.
Gospels written at a later date had a smaller chance of being included. Gradually, a consensus emerged and there were political considerations. If the Canon contained a large body of the Jewish scriptures, it would not have appealed to the gentiles. The canon also had to claim antiquity and Marcion's canon was too recent.
The Gnostic texts were more philosophical and could only be understood by an elite. They were opposed by the early church fathers. The canon had to have a wide appeal within the Roman empire. When Emperor Constantine converted in 312, he was looking for a religion that could unify his fragmented empire. Without Constantine, there would be no western Christianity. Now this version could confront the Roman empire. It was the Roman churches that led the compilation of the canon and gospels like Thomas, though popular but with an eastern appeal, was rejected. Mark's gospel was written in Rome and was accepted. Bishops travelled widely to exclude 'heretical' works and the canon came to include works that were at home to Greek and Roman ideas. On example is the very beginning of St John's Gospel that introduces the notion of Logos (the Word).