I understand that in order for a marriage to be valid the couple must consummate the marriage at least once. However, as I understand it, Mary and Joseph did not consummate their marriage. So, how do I resolve this apparent contradiction?
The exchange of vows makes a marriage valid. Consummation makes it indissoluble.
Can. 1057 §1. The consent of the parties, legitimately manifested between persons qualified by law, makes marriage…
Can. 1061 §1. A valid marriage between the baptized is called ratum tantum if it has not been consummated; it is called* ratum et consummatum* if the spouses have performed between themselves in a human fashion a conjugal act which is suitable in itself for the procreation of offspring, to which marriage is ordered by its nature and by which the spouses become one flesh.
Can. 1141 A marriage that is* ratum et consummatum* can be dissolved by no human power and by no cause, except death.
Can. 1142 For a just cause, the Roman Pontiff can dissolve a non-consummated marriage between baptized persons or between a baptized party and a non-baptized party at the request of both parties or of one of them, even if the other party is unwilling.
While actual consummation is not required for a valid marriage, its potential is (Can. 1084 §1).
Therefore Mary & Joseph did indeed have a valid (ratum tantum) marriage through their marital vows.