Thank you. Excellent question.
The gospels were written 40-70 years after Yeshua's death... that's when the texts themselves were composed by anonymous communities.
The names Matthew, Mark, Luke, and John weren't added until the 2nd century. And they weren't officially canonized as scripture until the 4th century councils.
Three separate timelines. The writing, the attribution, and the canonization all happened centuries apart.
Mark was written first, around 70 CE. Matthew and Luke came later, around 80-85 CE, and scholars believe both authors used Mark as their source; along with a hypothetical lost document they call Q. John was written last, around 90-100 CE.
None of these authors knew each other. None of them met Yeshua. They were compiling oral traditions and earlier written fragments decades after his death, each shaped by the theological concerns of their own communities.
As for the Gnostic gospels—Thomas, Philip, Mary, Judas—those came even later. Most scholars (including Bart D. Ehrman) date them to the 2nd and 3rd centuries, well after the canonical gospels.
Some scholars like Elaine Pagels argue that Thomas may contain early oral traditions, but even she dates the text as we have it to around 90-140 CE at the earliest.
While some Gnostic texts, like Thomas (one of my favorites), may preserve early material, most scholars see them as reflecting later theological developments rather than earlier eyewitness accounts.