Mary grew up in the temple and should have been well instructed in scripture/torah there. But because Mary was extremely humble, most people reading the bible or living at her time would not realise indeed how much she knew about scripture. But there are hints: the Magnificat is one of them.
By the way, it seems (according to tradition, if I am not mistaken) Mary homeschooled Jesus and his 2 cousins Judas Thaddeus and James. She could have been able to do that only if she was well instructed in scripture.
As for Mary not telling Joseph about the origin of her pregnancy, I can imagine she was burning to tell Joseph, because he of course came to know about it by observing her when she came back from Hebron after visiting Elizabeth. Scripture tells us that Joseph wanted to secretely and honorably cancel the engagement. She sould have been suffering very intensely feeling accused or regarded with contempt by Joseph her fiancee, and would have loved to clear out the misunderstanding by talking directly to Joseph.
So why did she not say anything? The Holy Spirit told her to remain quiet and trust God in all things. That act in itself of trusting God with her suffering against all logic in that dark night of hers gave her alot of merit and favour in the eyes of God as she always had from her conception and her behaviour is consistent with what the Angels (e.g. Gabriel) already knew about her, i.e. a woman full of Grace.
At the end we all know how that part of the story ended - Mary, despite being pregnant without comitting adultery/fornication remained quiet and did not justify herself. God justified Mary by sending an Angel to Joseph in a dream and he got to know the truth in the most supernatural of ways. We should all learn from this beatiful lesson of trust in God.
It does not matter what people think about us, all that matters is what God thinks about us.