The first of the two premises—that the Church would say Mary and Joseph did not have a valid marriage—is false. This objection has been dealt with a long time ago. Thomas Aquinas considers it in the Summa Theologiae (cf. ST III:29:2). Basically, a marriage is valid as long as the two parties exchange valid matrimonial consent, which involves the exchange of a right to marital congress with the spouse. The intent to exercise that right is not required for the consent to be valid. Therefore, according to the standard account, the marriage between Mary and Joseph was valid because the right was exchanged even though it was not intended by the parties to be used. There have been parallel cases down through history, and these are known as “Josephite” marriages, after St. Joseph.