The gospels tell us very little about Jesus’ early life. The most relevant verses are in Luke 2:
And the child grew and became strong, filled with wisdom. And the favor of God was upon him. (Luke 2:40)
After three days they found him in the temple, sitting among the teachers, listening to them and asking them questions. 47 And all who heard him were amazed at his understanding and his answers. (Luke 2:46 – 47)
And Jesus increased in wisdom and in stature and in favor with God and man. (Luke 2:52)
We would expect that Jesus was educated both at home and at the synagogue, as appears to have been usual. However, his wisdom and understanding was so very unusual that this cannot have been his only method of learning. I assume it came from a combination of wisdom and instruction from God, from his parents, and from his school as well as considerable time spent learning and meditating on God’s word.