Mecca had a local tribe of Jews and heretical Christians that Muhammad could very easily learn Biblical and Talmudic stories from. Ibn Ishaq in his biography on Muhammad (edited by Ibn Hishām), and Muqatil ibn Sulayman in his Tafsir, reported that Muhammad used to be taught by Christian slaves named Jabr and Addas on the hill of Marwa as well as having reported that Muhammad was taught by a Jewish man named Abu Fakayha Yasar. (Muqatil b. Sulayman, Tafsir al-Qur'an, 2; Foreign slaves in Mecca and Medina in the formative Islamic period p. 345-350)
Many scholars believe the Qur'an began in a proto form as a liturgical lectionary among Arabian Nestorian Christians that was eventually redacted with various "revelations" that Muhammad received, and in a sense, Muhammad's revelations almost serve as a Midrash around the core of the original text; indeed when we read the very first chapter of the Qur'an, Al-Fatihah, we find that it does not sound like a revelation from Allah to Muhammad, as Muslims claim, but rather a liturgical prayer:
(See: The Syro-Aramaic Reading Of The Qur'an, by Christoph Luxenberg for more info on this topic)
We also find in the Qur'an the main title for Jesus being "Son of Mary" instead of "Son of God" (Qur'an 4:171, Qur'an 9:31, Qur'an 5:72-75, Qur'an 5:116, etc.) which is exactly what the Nestorians (a heretical Christian sect in Arabia, Mesopotamia, and Persia in the 7th century) used to refer to Jesus. Further Muhammad refers to the Trinity as making God "the third of three" (Qur'an 5:73) and also he includes Mary in the Trinity (Qur'an 5:116, Qur'an 4:171), which was likely a Nestorian polemic against the Monophysites (another heretical Christian sect in southern Arabia, Egypt, and Ethiopia in the 7th century) who believed Jesus's human and divine nature mashed together to form a distinct divinity. This means that Nestorian Christianity heavily influenced Islamic Christology.
Further we see in the Qur'an numerous Talmudic stories like the story of Abraham and the Idols (Qur'an 21:51-70) which cannot be found in the Bible but originated only in the Talmud in the 2nd century; as well as psuedo-New Testament material not found in the current Christian New Testament but which was widely circulating among heretical Christian sects in Arabia and Mesopotamia at the time of Muhammad such as the story of Mary giving birth to Jesus under a palm tree (Qur'an 19:22-26) which cannot be found in the current New Testament but can be found in the Arabic Pseudo-Gospel of Matthew written about 10 years before Muhammad is claimed to have received his revelation.
Essentially Muhammad was heavily influenced by the local Nestorian Christians and Jews of Mecca and Medina who taught him much about their respective faiths. He took what he learned, claimed he had some revelations from their God, combined what he had learned from the Jews and Christians with a few already existing pagan Arabian practices (such as the Hajj), and had many of his supposed revelations redacted in a proto-Qur'an used as a liturgical text among local Christian to give birth to what we now know as the Qur'an, and boom Islam was born.
Muhammad wasn't even the only supposed Arabian prophet of that time, it's just that he proved most influential only because he got into conflict with the Quraysh and then went onto conquer Arabia from there. Other supposed prophets include: Musaylimah, Al-Aswad Al-Ansi, and most interestingly Zayd ibn Amr who lived before Muhammad, and who belong to a sect scholars call "the followers of Abraham." This sect was neither Jewish nor Christian but adopted elements from both and opposed idolatry, claiming to have worshiped the God of Abraham alone. They also promoted Hagarism, an early form of Arab supremacy. Muhammad likely picked up on all these ideas, and it's very likely Muhammad was influenced or even came into contact with this sect.