Luke 2:41-51 describes that event--Jesus was supposed to return with his parents to Nazareth after the Feast of the Passover at Jerusalem. It was custom back then to travel with other people in big herds, with children in a group separate from the parents, so that explains why his parents took so long to realize he was gone.
When they go back and find him, Mary said, "Son, why have you treated us so? Behold, your father and I have been searching for you in great distress." He said, "Did you not know that I must be in my Father's house?" And they did not understand the saying that he spoke to them. And he went down with them and came to Nazareth and was submissive to them.
Neither Jesus nor his parents did anything wrong. His parents did nothing wrong, and Jesus can't be wrong because that would be against God's nature and he wasn't scolded for doing anything wrong. It's not entirely clear what was going on in Jesus' head, but you can say with confidence that nobody did anything wrong.
I think this is like an awkward mishap--a natural quirk in a healthy relationship. Romans 8:22 says " For we know that the whole creation has been groaning together in the pains of childbirth until now." You might say that because relationships are part of creation, they too are groaning for redemption, being affected by the fall.
As far as the actual intent of including the passage--Luke may have included it to mark the closure of Jesus' childhood before his ministry begins. His infancy begins and ends in the temple. The boy Jesus said, "I must be in my Father's house." Jesus and the temple have an apparently strong connection.
To learn from the ELders, listening and asking questions
No Jesus was not gambling at the Temple at age 12. Luke 2: 41-50 tells us that every year Joseph and Mary and Jesus would travel to Jerusalem for the Passover. When Jesus was there at age 12, His parents missed Him in their company on the way home to Nazareth. Returning to Jerusalem they found Jesus in the Temple, listening to and asking questions of the teachers there. Jesus even at age 12 would not gamble and there was no gambling in the temple.
Jesus was 12 years old when his parents lost him during their pilgrimage to Jerusalem. They found him discussing and listening to the teachers in the temple.
After Jesus was 12 years, he got lost in the temple for three days.
Jesus preached mostly in the temple at Jerusalem at the beginning and at the end of his earthly ministry. He also preached in Jerusalem to the scribes in the temple when he was 12 years old.
12 years old
Yes, at the age of 12 Jesus wandered off from his parents and was listening to the teachers at the temple, also speaking to them; they were impressed with his knowledge. Also, after the death of John the Baptist, Jesus overturned the moneychangers' tables in the temple, thus angering them and prompting their decision to kill Him.
Jesus was likely around 40 days old when he was presented at the temple in Jerusalem, following the Jewish tradition outlined in the Old Testament (Luke 2:22-24).
Jesus was presented in the temple to the priest Simon, as he was dedicated there.
Passover
I can't imagine that he didn't stay close by the whole time Jesus was at the Temple, so it's reasonable to assume that he was there for the circumcision and naming.
strayed away from his family at 12 yrs of age and was found at the temple
Jesus did not rebuild the temple.