We understand that only after a marriage is consumated does it become a valid marriage. If Mary is perpetually a virgin and did not have relations with Joseph, how could their marriage have then valid?
Your understanding is incorrect. The consumation of the marriage completes it. But the marriage is valid immediatey after the couple have pronouced their vows. Mary and Joseph were validly married.
DISCLAIMER: Catholic Answers has turned over the archive to Catholic-Questions.org and no longer owns, manages, or moderates the forums. For additional apologetics resources please visit www.catholic.com.