What is wrong with a baby passing through a birth canal that would cause one to lose one's virtue?
In many cases today, when a baby is born it causes a tear or rip in the mother's perineum. Typically the doctor will stitch up the tear, although sometimes they simply let it heal on its own, depending on the severity of the tear. This is an example of bodily damage (loss of bodily integrity) being caused in the birth process. Similarly, in a woman whose hymen is intact, giving birth would cause such damage to the hymen. Her physical integrity would be corrupted (which shouldn't be mistaken for spiritual or moral corruption). But Christ the Savior could not violate the physical integrity of His mother, and hence the Church teaches that Mary remained a virgin (in all aspects) even throughout the birth of Christ.
Virginity has both a material and a formal aspect. The formal is more important (which is why St. Augustine argues that virgins who are raped and do not consent, do not lose their virginity, even if they lose their physical integrity), but that does not mean that the material aspect is worthless or insignificant.
-A8