We are not told how long Mary stayed with Elizabeth and Zechariah.
The word does not go in any details other than the greeting that took place between Elizabeth and Mary.
At the time of her visit Zechariah was not able to speak, as the Angel who told him about Elizabeth, gave him a bit of discipline, for not trusting him more when he was told about Elizabeth having a baby. He was finally chosen to be in the temple and finally able to the do the temple duties as an old man, and all of a sudden while in the temple, an angel appeared to him.
In Luke chapter one verse eleven it says:
[While Zechariah was in the sanctuary, an angel of the Lord appeared to him, standing to the right of the incense altar. Zechariah was shaken and overwhelmed with fear when he saw him. But the angel said, “Don’t be afraid, Zechariah! God has heard your prayer. Your wife Elizabeth will give you a son, and you are to name him John.”]
The conversation continued and Zechariah answered the angel with a bit of a question.
(I can’t really blame him for asking)
[“Zechariah said to the angel, “How can I be sure this will happen? I am an old man now and my wife is also well along in years.”
Then the angel said, “I am Gabriel! I stand in the very presence of God.
It was he who sent me to bring you this good news!
But now, since you didn’t believe what I said, you will be silent and unable to speak until the child is born.
For my words will certainly be fulfilled at the proper time.”
So we find Mary visiting Elizabeth and Zechariah who had no voice.
One could assume she stayed until the baby came, as Elizabeth was in her sixth month which perhaps could put Mary at four months.
That might also have helped Mary learn of labor and delivery.
We are not told how she got there, or how far it was to travel there.
We do know this is where Mary says her magnificate prayer. The song of Mary.
There are many details we are not told, but what we do know, it is never a good idea to question an angel.