It's still a jolt for some people to realize this, but the Bible did not fall down out of the sky, leather-bound and gold-monogrammed with the words of Christ in red, in 95 AD. Rather the canon of Christian Scripture slowly developed over a period of about 1500 years. That does not mean, of course, that Scripture was being written for 1500 years after the life of Christ. Rather, it means that it took the Church some fifteen centuries to formally and definitively state which books out of the great mass of early Christian and pseudo-Christian books constituted the Bible.
The process of defining the canon of Scripture is an example of what the Church calls "development of doctrine". This is a different thing than "innovation of doctrine". Doctrine develops as a baby develops into a man, not as a baby grows extra noses, eyes, and hands. An innovation of doctrine would be if the Church declared something flatly contrary to all previous teaching ("Pope John Paul Ringo I Declares the Doctrine of the Trinity to No Longer Be the Teaching of the Church: Bishop Celebrate by Playing Tiddly Winks with So-Called 'Blessed Sacrament'"). It is against such flat reversals of Christian teaching that the promise of the Spirit to guard the apostolic Tradition stands. And, in fact, there has never ever been a time when the Church has reversed its dogmatic teaching. (Prudential and disciplinary changes are another matter. The Church is not eternally wedded to, for instance, unmarried priests, as the wife of St. Peter can tell you.)
But though innovations in doctrine are not possible, developments of doctrine occur all the time and these tend to apply old teaching to new situations or to more completely articulate ancient teaching that has not been fully fleshed out. So, for example, in our own day the Church teaches against the evils of embryonic stem cell research even though the New Testament has nothing to say on the matter. Yet nobody in his five wits claims that the present Church "invented" opposition to embryonic stem cell research from thin air. We all understand that the Church, by the very nature of its Tradition, has said "You shall not kill" for 2,000 years. It merely took the folly of modern embryonic stem cell research to cause the Church to apply its Tradition to this concrete situation and declare what it has always believed.
Very well then, as with attacks on sacred human life in the 21st century, so with attacks on Sacred Tradition in the previous twenty. Jesus establishes the Tradition that he has not come to abolish the Law and the Prophets but to fulfill them (Mt 5:17). But when Tradition bumps into the theories of early Jewish Christians that all Gentiles must be circumcised in order to become Christians, the Council of Jerusalem (Acts 15) is still necessary to authoritatively flesh that Tradition out. Moreover, the Council settles the question by calling the Bible, not to the judge's bench, but to the witness stand. Scripture bears witness to the call of the Gentiles, but the final judgment depends on the authority of Christ speaking through his apostles and elders whose inspired declaration is not "The Bible says..." but "It seemed good to the Holy Spirit and to us..." (Acts 15:28).
In all this, the Church, as ever, inseparably unites Scripture as the light and Sacred Tradition as the lens through which it is focused. In this way the mustard seed of the Kingdom continues to grow in that light, getting more mustardy, not less.
How then did Tradition develop with respect to the canon of Scripture?
In some cases, the Church in both east and west has a clear memory of just who wrote a given book and could remind the faithful of this. So, for instance, when a second century heretic named Marcion proposed to delete the Old Testament as the product of an evil god and canonize the letters of Paul (but with all those nasty Old Testament quotes snipped out), and a similarly edited gospel of Luke (sanitized of contact with Judaism for your protection), the Church responded with local bishops (in areas affected by Marcion's heresy) proposing the first canons of Scripture.
Note that the Church seldom defines its teaching (and is in fact disinclined to define it) till some challenge to the Faith (in this case, Marcion) forces it to do so. When Marcion tries to take away from the Tradition of Scripture by deleting Matthew, Mark and John and other undesirable books, the Church applies the basic measuring rod of Tradition and says, "This does not agree with the Tradition that was handed down to us, which remembers that Matthew wrote Matthew, Mark wrote Mark and John wrote John.
Matthew also issued among the Hebrews a written Gospel in their own language, while Peter and Paul were evangelizing in Rome and laying the foundation of the Church. After their departure, Mark, the disciple and interpreter of Peter, also handed down to us in writing what had been preached by Peter. Luke also, the companion of Paul, set down in a book the Gospel preached by him. Afterwards, John, the disciple of the Lord who reclined at his bosom also published a Gospel, while he was residing at Ephesus in Asia. (Irenaeus, Adversus Haereses, 3, 1, 1)
In other words, there is, we might say, a Standard of Roots (based on Sacred Tradition) by which the Church weighs her canon. So when various other heretics, instead of trying to subtract from the generally received collection of holy books, instead try to add the Gospel of Thomas or any one of a zillion other ersatz works to the Church's written Tradition, the Church can point to the fact that, whatever the name on the label says, the contents do not square with the Tradition of the Church, so it must be a fake. In other words, there is also a Standard of Fruits. It is this dual standard of Roots and Fruits by which the Church discerns the canon -- a dual standard which is wholly based on Sacred Tradition. The Church said, in essence, "Does the book have a widespread and ancient tradition concerning its apostolic origin and/or approval? Check. Does the book square with the Tradition we all learned from the apostles and the bishops they gave us? Check. Then it is to be used in public worship and is to be regarded as the word of God."
It was on this basis the early Church also vetoed some books and accepted others -- including the still-contested-by-some-Protestants deuterocanonical books of Tobit, Wisdom, Judith, 1 and 2 Maccabees, Sirach and Baruch as well as some pieces of Daniel and Esther. For the churches founded by the apostles could trace the use of the Septuagint version of the Old Testament in public worship (a Greek translation of the Old Testament which includes all these books) back to the apostles. In fact, many of the citations of Old Testament Scripture by the New Testament writers are, in fact, citations of the Septuagint (see, for example, Mark 7:6-7, Hebrews 10:5-7). Therefore, the Body of Christ living after the apostles simply retained the apostles' practice of using the Septuagint on the thoroughly traditional grounds, "If it's good enough for them, it's good enough for us." In contrast, the churches had no apostolic tradition handed down concerning the use of, say, the works of the Cretan poet Epimenides (whom Paul quotes in Acts 17), therefore they did not regard his works as Scripture, even though Paul quotes him. It was by their roots and fruits that the Church's books were judged, and it was by the standard of Sacred Tradition that these roots and fruits were known.
These Root and Fruit standards are even more clearly at work in the canonization of the New Testament, especially in the case of Hebrews. There was, in fact, a certain amount of controversy in the early Church over the canonicity of this book (as well as of books like 2 Peter, Jude, and Revelation). Some Fathers, especially in the west, rejected Hebrews (in no small part because of its lack of a signature). Yet the Church eventually accepted it. How? It was judged apostolic because, in the end, the Church discerned that it met the Roots and Fruits measure when stacked up against Sacred Tradition.
The Body of Christ had long believed that Hebrews said the same thing as the Church's Sacred Tradition handed down by the bishops. Thus, even Fathers (like Irenaeus) who rejected it from their canon of inspired Scripture still regarded it as a good book. That is, it had always met the Fruits standard. How then did it meet the Roots standard? In a nutshell, despite the lack of attestation in the text of Hebrews itself, there was an ancient tradition in the Church (beginning in the East, where the book was apparently first sent) that the book originated from the pen of St. Paul. That tradition, which was at first better attested in the east than in the west (instantaneous mass communication being still some years in the future) accounts for the slowness of western Fathers (such as Irenaeus) to accept the book. But the deep-rootedness of the tradition of Pauline authorship in the East eventually persuaded the whole Church. In short, as with the question of circumcision in the book of Acts, the status of Hebrews was not immediately clear even to the honest and faithful (such as Irenaeus). However, the Church in council, trusting in the guidance of Holy Spirit, eventually came to consensus and canonized the book on exactly the same basis that the Council of Jerusalem promulgated its authoritative decree: "It seemed good to the Holy Spirit and to us..."
Conversely, those books which the Church did not canonize as part of the New Testament were rejected because, in the end, they did not meet both the Root and Fruit standards of the Church's Sacred Tradition. Books like the Didache or the Shepherd of Hermas, while meeting the Fruit standard, were not judged to meet the Root standard since their authors were not held to be close enough to the apostolic circle -- a circle which was, in the end, drawn very narrowly by the Spirit-led Church and which therefore excluded even Clement since he, being "in the third place from the Apostles" was not as close to the apostles as Mark and Luke (who were regarded as recording the gospels of Peter and Paul, respectively). The Church, arch-conservative as ever, relied on Sacred Tradition, not to keep adding to the New Testament revelation but to keep it as lean and close to the apostles as possible. This, of course, is why books which met neither the Root nor Fruit standards of Sacred Tradition, such as the Gospel of Thomas, were rejected by the Church without hesitation as completely spurious.
Not that this took place overnight. The canon of Scripture did not assume its present shape till the end of the fourth century. It was defined at the regional Councils of Carthage and Hippo and also by Pope Damasus and included the deuterocanonical books. It is worth noting, however, that, because these decisions were regional, none of them were dogmatically binding on the whole Church, though they clearly reflected the Sacred Tradition of the Church (which is why the Vulgate or Latin Bible--which was The Bible for the Catholic Church in the West for the next 1200 years looks the same as the Catholic Bible today). Once again, we are looking at Sacred Tradition which is not fully developed until a) the Reformation tries to subtract deuterocanonical books from Scripture and b) the Council of Trent in the mid-1500s finally makes that Tradition fixed and binding. This is the origin of the myth that the Catholic Church "added" the deuterocanonical books to Scripture at Trent. It is as historically accurate as the claim that the Catholic Church "added" opposition to embryonic stem cell research to its tradition during the pontificate of Pope John Paul II.
In summary then, the early Church canonized books because they were attested by apostolic tradition. The books we have in our Bibles (and the ones we don't) were accepted or rejected according to whether they did or did not measure up to standards which were based entirely on Sacred Tradition and the divinely delegated authority of the Body of Christ.