Q. How could John the Baptist have written the Gospel of John, when that same gospel tells about his death?
John the Baptist wasn't the author of the Gospel of John; it was written by another man who was also named John. He was one of Jesus' 12 disciples, and therefore was an eyewitness to the events he recorded.
God has given us the Bible so we can learn about him and come to know him. Every time you open it, ask God to help you understand what it is saying. Remember that the Gospels were written to tell us about Jesus. If you read through the Gospel of John, for example, ask yourself what it says about him – who he is, what he did, and so forth.
Remember, the Bible wasn't written just to satisfy our curiosity. God gave the Bible to us so we could come to know him – not just know about him, but know him in a personal way and walk with him as our friend.
How is this possible? It is possible because Jesus Christ came into the world to reveal God's love to us.