At the end of Matthew’s gospel, Jesus sends the disciples out to “make disciples of all nations, baptizing them in the name of the Father and of the Son and of the Holy Spirit (Matthew 28:19). This is the origin of the Church’s “trinitarian formula.”
The understanding of the relationship between the three persons of the Trinity itself developed over the first few centuries of Christianity as church leaders pondered the many and various passages in the New Testament about Jesus, the Father, and the Holy Spirit. Some passages speak of Jesus as the Son of God (for example, Luke 1:35). There are passages in which Jesus promises that God will send the Holy Spirit after Jesus’ death (John 14:26). Some passages speak of Jesus and the Father as one (John 17:22-23).
How do we wrap our minds around this? We can’t — at least not fully. The teaching on the trinity is one of those teachings that tries to articulate a mystery that is beyond us as humans. Our language of God as Father, Son, and Holy Spirit is our limited human attempt to point to the relationship between a loving creator, a man who was fully human and fully God, and the spirit of love that flows between them.