One answer that has been suggested is the Infancy Gospel of James (AKA The Protoevangelium of James). This document dates to roughly the middle of the second century and focuses largely on the person of Mary from her birth to the birth of Jesus. As the central character, Mary's honor and purity are defended in great detail. Mary's virginity is repeatedly demonstrated—including when she is six-months pregnant and endures an ordeal by the high priest. Since she survives drinking poison, the priest says, "If the Lord God has not made manifest your sins, neither do I judge you."
Most important to our question comes immediately after the miraculous birth of Jesus:
And the midwife went forth out of the cave, and Salome met her. And she said to her: "Salome, Salome, I have a strange sight to relate to thee: a virgin has brought forth—a thing which her nature admits not of." Then said Salome: "As the Lord my God liveth, unless I thrust in my finger, and search the parts, I will not believe that a virgin has brought forth."
And the midwife went in, and said to Mary: "Show thyself; for no small controversy has arisen about thee." And Salome put in her finger, and cried out, and said: "Woe is me for mine iniquity and mine unbelief..."—Roberts-Donaldson English Translation (with added punctuation)
In other words, the midwife and Salome are said to have inspected Mary's hymen immediately after the birth in order to show that Mary was a virgin before and after the event.
So here's my speculative sequence of events:
- Jesus was born from the virgin Mary as described in Luke and Matthew.
- Sometime later, opponents of Christianity questioned this doctrine.
- In response, someone (no scholars believe it was written by James the Just) wrote the Infancy Gospel to defend Mary's honor.
- Even though it was not accepted as canonical, many early Christians accepted the story of Mary's perpetual virginity and even expanded on it. (The Protoevangelium does not speak of Mary's life after the birth of Jesus, so it doesn't claim she never had other children.)
- The doctrine of the perpetual virginity of Mary became enshrined in tradition.
When the Reformation examined church tradition against scripture, it understandably focused on what it considered most important and Mariology was not high on the list. Therefore, the question of whether Mary remained a virgin after Jesus' birth was not immediately questioned.
I should point out that as far as it goes, perpetual virginity is an innocuous doctrine to the Protestant worldview. That Christ was born of a virgin is a matter asserted by the earliest Creeds and the gospels themselves, so it wouldn't be much of a stretch if it turned out that Mary remained a virgin—what's a little more miracle after all? But Protestants generally agree that perpetual virginity is a) not true and b) part of a larger set of doctrines that misplace the importance of Mary. That's why we tend to be opposed to the doctrine.
As you point out, pre-Reformation Christians did read scripture. But they did not have many of the tools of criticism that were developed at about the same time. Therefore, the doctrine of perpetual virginity was placed beside the gospel accounts and the differences were harmonized. The harmonized interpretation then became part of church's tradition. When the doctrine of sola scriptura was introduced, the differences were interpreted as denying perpetual virginity, which was therefore dropped. It's not necessarily even a matter of Protestants being better at interpretation. Rather, I would say that Protestants are more willing to be skeptical of tradition.
If Protestants venture any theory at all, it is that perpetual virginity defense entered the church's tradition very early on in its history in response to charges that Christ's birth was entirely natural (and even illegitimate). Understandably, the tradition may have exaggerated the facts at times.