Another "historical approach" remark - there were some Christians in Arabia in Muhammad's times, so even if Muhammad was illiterate, he could ask some of his Christian neighbors and listen to the stories. But most of these "Christians" were not orthodox and many of them belonged to sects today refered to as gnostics, not Christians. Bible as we know it wasn't recognized as Holy Spcripture by all of them, and translations of Bible were rare and often poor. This explains many refences to Childhood Gospel and other apocryphas (for example creation of the birds by child Jesus) in Quran, and also some statements that originated in misunderstanding Bible. For example in Bible John the Baptist was first of this name in his family, but in Quran Yahya (John the Baptist) was the first of this name in general (from all mankind).
Muhammad simply knew some second-hand "Bible stories", and we won't find out who originally misunderstood them.
Of course, some old testament stories might have survived in Arabic culture since Abraham.
EDIT - some sources from both holy writs to back up my example with John the Baptist:
Luke 1:5-25
5 In the time of Herod king of Judea there was a priest named
Zechariah, who belonged to the priestly division of Abijah; his wife
Elizabeth was also a descendant of Aaron. 6 Both of them were upright
in the sight of God, observing all the Lord’s commandments and
regulations blamelessly. 7 But they had no children, because Elizabeth
was barren; and they were both well along in years.
8 Once when Zechariah’s division was on duty and he was serving as
priest before God, 9 he was chosen by lot, according to the custom of
the priesthood, to go into the temple of the Lord and burn incense. 10
And when the time for the burning of incense came, all the assembled
worshipers were praying outside.
11 Then an angel of the Lord appeared to him, standing at the right
side of the altar of incense. 12 When Zechariah saw him, he was
startled and was gripped with fear. 13 But the angel said to him: “Do
not be afraid, Zechariah; your prayer has been heard. Your wife
Elizabeth will bear you a son, and you are to give him the name John.
14 He will be a joy and delight to you, and many will rejoice because
of his birth, 15 for he will be great in the sight of the Lord. He is
never to take wine or other fermented drink, and he will be filled
with the Holy Spirit even from birth. 16 Many of the people of
Israel will he bring back to the Lord their God. 17 And he will go on
before the Lord, in the spirit and power of Elijah, to turn the hearts
of the fathers to their children and the disobedient to the wisdom of
the righteous—to make ready a people prepared for the Lord.”
18 Zechariah asked the angel, “How can I be sure of this? I am an old
man and my wife is well along in years.”
19 The angel answered, “I am Gabriel. I stand in the presence of God,
and I have been sent to speak to you and to tell you this good news.
20 And now you will be silent and not able to speak until the day this
happens, because you did not believe my words, which will come true at
their proper time.”
21 Meanwhile, the people were waiting for Zechariah and wondering why
he stayed so long in the temple. 22 When he came out, he could not
speak to them. They realized he had seen a vision in the temple, for
he kept making signs to them but remained unable to speak.
23 When his time of service was completed, he returned home. 24 After
this his wife Elizabeth became pregnant and for five months remained
in seclusion. 25 “The Lord has done this for me,” she said. “In these
days he has shown his favor and taken away my disgrace among the
people.”
And luke 1:57-66
57 When it was time for Elizabeth to have her baby, she gave birth to
a son. 58 Her neighbors and relatives heard that the Lord had shown
her great mercy, and they shared her joy.
59 On the eighth day they came to circumcise the child, and they were
going to name him after his father Zechariah, 60 but his mother spoke
up and said, “No! He is to be called John.”
61 They said to her, “There is no one among your relatives who has
that name.”
62 Then they made signs to his father, to find out what he would like
to name the child. 63 He asked for a writing tablet, and to everyone’s
astonishment he wrote, “His name is John.” 64 Immediately his mouth
was opened and his tongue was loosed, and he began to speak, praising
God. 65 The neighbors were all filled with awe, and throughout the
hill country of Judea people were talking about all these things. 66
Everyone who heard this wondered about it, asking, “What then is this
child going to be?” For the Lord’s hand was with him.
And the extract from this in Quran (Surah 19 - Maryam, verses 2-10):
[This is] a mention of the mercy of your Lord to His servant Zechariah
When he called to his Lord a private supplication.
He said, "My Lord, indeed my bones have weakened, and my head has
filled with white, and never have I been in my supplication to You, my
Lord, unhappy.
And indeed, I fear the successors after me, and my wife has been
barren, so give me from Yourself an heir
Who will inherit me and inherit from the family of Jacob. And make
him, my Lord, pleasing [to You]."
[He was told], "O Zechariah, indeed We give you good tidings of a boy
whose name will be John. We have not assigned to any before [this]
name."
He said, "My Lord, how will I have a boy when my wife has been barren
and I have reached extreme old age?"
[An angel] said, "Thus [it will be]; your Lord says, 'It is easy for
Me, for I created you before, while you were nothing.' "
[Zechariah] said, "My Lord, make for me a sign." He said, "Your sign
is that you will not speak to the people for three nights, [being]
sound."
I see nothing really new in the Quran version, just omission of many details, and changes concerning the time Zechariah couldn't speak and the detail with previous Johns. This name was definitely not unknown in Izrael before (I remember one John in the Maccabean books, and I don't think he's the only one mentioned in Old Testament).