First of all, we very likely DO know who wrote the gospels. It is virtually certain that Luke wrote Luke, and, based on the evidence, highly likely that Matthew, Mark and John wrote the gospels known by those names. So, in the way you are asking the question, in my opinion, you are overstating the level of doubt about who wrote these gospels. We do know who wrote them, but just not with 100% certainty.
Second, what matters is whether these gospels are true reflections of what happened and what Jesus said. What matters is that they are inspired. These gospels are clearly inspired, and are a faithful reflection of what actually happened. The church in the first century, which included thousands of people who had personally met Jesus, agreed that these gospels were reliable, and they would know. The identity of the author is not the key question. It is a somewhat important side issue, but certainly not the main issue. The main issue is who Jesus is, what he did and what he said. So, whether the person we know of as Mark wrote the gospel we know of as the Gospel of Mark is a relatively minor point. You can trust Matthew because it is true, because it was approved by the very early church as being an “apostolic” (ie approved by the living apostles) book, and as it tells us the true story of the deeds and words of Jesus. The book does not claim to be written by Matthew, so the identity of the author is not essential.
Third, the fact is that a quite large portion of the Bible was written by unknown authors. We do not know who wrote Genesis, Joshua, Judges, Ruth, 1,2 Samuel, 1,2 Kings, 1,2 Chronicles, most of Proverbs, much of Psalms, Hebrews and other biblical writings. These writings are part of the canon of Scripture because they are inspired by God. I trust Genesis because the evidence is that it is inspired by God, although I do not know the name of the people who wrote it and put it together (there is almost certainly more than one contributor to Genesis). Not knowing the identity of the author of an inspired, canonical book of the Bible does not reduce our trust in these books. The same is true with the four gospels.
You can trust the gospels because “all Scripture is inspired by God.” (2 Timothy 3:16)