If Jesus and God and the Holy Spirit are a Trinity and of the same substance, then to whom and why was Jesus praying?
I was told once that it was to teach His disciples how to pray, yet that can't be the whole truth because He often prayed alone. Thanks!
Yes, Jesus and God are of the same substance as the confession of faith says.
Athanasian Creed (A.D. 325)
We worship one God in Trinity, and Trinity in Unity; neither confounding the Person: nor divided in the Substance [Essence]. For there is one Person of the Father: another of the Son: and another of the Holy Spirit. But the Godhead of the Father, of the Son, and of the Holy Spirit, is all one: the Glory equal, the Majesty coeternal. Such as the Father is: such is the Son: and such is the Holy Spirit. The Father uncreate [uncreated]: the Son uncreate [uncreated]: and the Holy Spirit uncreate [uncreated]. The Father incomprehensible [unlimited]: the Son incomprehensible [unlimited]: and the Holy Spirit incomprehensible [unlimited, or infinite]. The Father eternal: the Son eternal: and the Holy Spirit eternal. And yet they are not three eternals: but one eternal. As also there are not three uncreated: nor three incomprehensibles [infinites]: but one uncreated: and one incomprehensible. So likewise the Father is Almighty: the Son Almighty: and the Holy Spirit Almighty. And yet they are not three Almighties: but one Almighty. So the Father is God: the Son is God: and the Holy Spirit is God. And yet they are not three Gods: but one God. So likewise the Father is Lord: the Son is Lord: and the Holy Spirit is Lord. And yet not three Lords: but one Lord. . . . And in this Trinity none is afore, or after another: none is greater, or less than another. But the whole three Persons are coeternal, and coequal. So that in all things, as aforesaid: the Unity in Trinity, and the Trinity in Unity, is to be worshipped . . .
This means that God the Father, God the Son, and God the Holy Spirit are all one God. They are one divine spirit. Yet when Jesus came to earth, He also became a man and took on human flesh. There is a lesson in the section entitled Solid Roots that can help provide more information on Jesus being both God and man. It is called Jesus Our Savior. It is here that we have one of the great mysteries in the Bible. The mystery is that Jesus was both God and man. The answer to your question is found in this mystery. Even though Jesus was God, as a man he prayed to God. Even though He was a man He forgave sins.
And Jesus seeing their faith said to the paralytic, “My son, your sins are forgiven.” But there were some of the scribes sitting there and reasoning in their hearts, “Why does this man speak that way? He is blaspheming; who can forgive sins but God alone?” (NASB) Mark 2:5-7
But the scribes were unwilling to accept Him as God. What a mystery! Jesus was both God and man. He experienced life as a human being would – that included prayer. As God He forgave sins.
There are several past questions and answers that explore the mystery of Jesus as the God-man. Here are three links: link1, link2 and link3. As man He could die for our sins. As God He became our perfect sacrifice so that we can live with God – Father, Son, and Holy Spirit – some day.