The MOST Theological Collection: Our Lady In Doctrine and Devotion
"IX. The Loss of Jesus and Finding in the Temple"
a) Reasons for the conduct of Jesus: Some, unfortunately, have called His action of staying behind disobedience, in obedience to the higher command of His Father. But this is very unsuitable. In Mat 3. 15 when John the Baptist was unwilling to baptize Him, Jesus said that it was right to fulfil everything that righteousness calls for. Strictly, there was no command of Mary or Joseph not to do as He did.
Why did He do so? There is a widespread pattern, revealed in Scripture, in which God wills to put people into situations in which they must, as it were, hold on to His will in the dark, i.e., without being able to see why or how it is possible. For example, Abraham had been told he would be the father of a great nation through Isaac. But then, when Isaac was still a little boy, God told him to offer Isaac in sacrifice. This seemed to conflict. Abraham did not question: he just went ahead, in the dark. If we would hold the majority opinion that the Jews did not know of retribution in the next life until the 2nd century B.C., we would say that they had to hold on in the dark: they knew God was just, but so often they saw that His justice did not work out even to the end of the life of an individual: the wicked would continue to prosper, the just to suffer. There are numerous other instances. The conduct of Jesus at age 12 is one, where Mary and Joseph had to hold on in the dark. At Cana it will be similar. And there are many other instances, cf. Wm. G. Most, Our Father's Plan, Trinity, 1988, chapter 14. The basic idea is this: The only thing free in a person is the free will. If one then aligns that will perfectly with the will of the Father, that is complete perfection. To align that will with the will of the Father in cases where it seems impossible - that requires a most intense holding to the will of God. That gives room for greater spiritual growth. (Cf. also the factor of somatic resonance, Our Father's Plan, chapter 16). Now Our Lady was full of grace even at the start. But her capacity, as it were, could grow. To put her in situations where she had to hold on in the dark was a sign of great love.
b) The question of Mary's knowledge:
Luke 2. 30 reports " And they did not understand the word he spoke to them." This does not mean that she did not know who He was. We already saw in a study of the OT prophecies and Targums that she did. What she would not grasp was the strange change in the pattern of His conduct: previously, always thoughtful, now quite different.