There is actually a very good explanation.
The “enrollment” was more likely to be an oath of allegiance to the emperor taken in 3BC, not the census taken for the purpose of taxation by Quirinius in 6AD. The historian Josephus writes that the emperor Augustus required every person in every Roman province to swear a public oath of allegiance at one time or another. This would explain why we don’t see an historical record of a “census” taking place at the time of Jesus’ birth - it was not a census but an oath of allegiance. The whole Roman empire had to profess emperor Augustus to be "Father’ of the empire and took the official title of “Father” in 2 BC.
Quirinius was provincial legate of Syria in 6AD. A legate is the head of a whole province, like a governor. Quirinius held this position for about a year and this is most certainly when the census for the purpose of taxation took place. Church Father Justin Martyr writes that Quirinius was also a “Procurator” in Judea at some point in his career. A procurator is much lower position than legate and so it makes sense that Quirinius was procurator of Judea earlier and became legate of Syria later. Tertullian confirms in his writings that Saturninus was official legate of Syria at the time of the Nativity.
There were different words for different types of governing roles and Luke uses the same word for Quinirius’s “governorship” as he does for Pontus Pilates governorship, a further indication that Luke is referencing an earlier position as proconsul of Judea rather than legate of Syria.
Quirinius was likely the administrator of a Judean oath-registration at around 3 BC while he was proconsul before conducting another census for the purpose of taxation in 6AD while he was legate. Mary was with child during the first oath-registration enrollment just prior to Cesar Augustus declaring himself to be “Father” rather than during the second taxation-census enrollment.
There is a pretty good consensus that this is what actually took place. There is a good essay about it in the Ignatius Study Bible.