Even though a different man wrote each of the four Gospels, the same Holy Spirit inspired each man. Inspiration is a special gift of the Holy Spirit given to the sacred authors (those who wrote the Bible) so that only the words that God wanted written down were written down.
Were Matthew, Mark, Luke, and John standing on the sidelines taking notes as Jesus preached or performed miracles? No. In fact, only two of the four, Matthew and John, were actual apostles and eyewitnesses, so you can't think of Matthew, Mark, Luke, and John as, say, reporters covering a story for the media.
Before the Gospels were written, the words and deeds of Jesus were told by word of mouth. In other words, the Gospels were preached before they were written. The spoken word preceded the written word. And after it was written, because the papyrus on which the scrolls were written was so fragile, expensive, and rare, most people didn't read the Word but heard it as it was spoken in church during Mass. The Church calls it the three-level development of the Gospel: first, the actual sayings and teachings of Christ; second, the oral tradition where the apostles preached to the people what they saw and heard; and third, the writing by the sacred authors to ensure that the message wouldn't be altered.
The New Testament was written between A.D. 40 and 100. St. Irenaeus (c. 130–200) in A.D. 188 was the first person to mention the four Gospels. But it wasn't until the Council or Synod of Carthage in A.D. 397 that the final and official judgment of the Church came out and explicitly listed the 27 books in the New Testament, including the four Gospels. St. Jerome (c. 341–420) was the first one to combine both the Old and New Testaments into one volume and to translate all the books from Hebrew, Aramaic, and Greek into Latin, which was the common tongue of his time. This Latin version of the Bible is the Vulgate. It took him from A.D. 382 to 405 to finish this monumental task, but he was the first person to coordinate the complete and whole Christian Bible.