There’s a few misunderstandings taking place here. Let’s go through them one at a time:
Celibacy means means not married, chastity is sexual relations in their proper context. A priest who sinfully engages in an affair violates chastity not celibacy. A priest who attempts civil marriage violates celibacy. Thus Mary and Joseph, even though Mary was ever virgin, did not live a celibate life. They refrained from sexual relations in their marriage.
In Catholic teaching consummation is not required for a valid marriage, only the ability to consummate is required. A non consummated marriage can be dissolved, however it is still a valid marriage. A consummated marriage cannot be dissolved. So it is untrue to state that a non consummated marriage is an invalid marriage, it is just not indissoluble
Mary and Joseph were married before the Catholic Church and canon law. They lived under Jewish law. There was nothing in the Jewish law that required consummation of marriage for it to be valid and legal. Under the religious laws of their time Mary and Joseph were truly married.
So, as you can see, the assertion that Mary and Joseph’s marriage was in contradiction to Catholic teaching is patently false and based on misconceptions and misunderstandings.