From the Catechism:
Mary - “ever-virgin”
499 The deepening of faith in the virginal motherhood led the Church to confess Mary’s real and perpetual virginity even in the act of giving birth to the Son of God made man.154 In fact, Christ’s birth "did not diminish his mother’s virginal integrity but sanctified it."155 And so the liturgy of the Church celebrates Mary as Aeiparthenos, the “Ever-virgin”.156
500 Against this doctrine the objection is sometimes raised that the Bible mentions brothers and sisters of Jesus.157 The Church has always understood these passages as not referring to other children of the Virgin Mary. In fact James and Joseph, “brothers of Jesus”, are the sons of another Mary, a disciple of Christ, whom St. Matthew significantly calls “the other Mary”.158 They are close relations of Jesus, according to an Old Testament expression.159
501 Jesus is Mary’s only son, but her spiritual motherhood extends to all men whom indeed he came to save: "The Son whom she brought forth is he whom God placed as the first-born among many brethren, that is, the faithful in whose generation and formation she co-operates with a mother’s love."160
One commentary states that the mystery of Christ’s becoming man is to be adored, not curiously inquired into. It was so ordered that Christ should partake of our nature, yet that he should be pure from the defilement of original sin, which has been communicated to all the race of Adam. I believe that this passage in Matthew is meant to deter the reader from straying into thinking that Jesus was just another person…and not the Son of God. I don’t think it has any reference to or should infer any relations took place “later”. We know that Mary was a consecrated Virgin. We know Joseph was quite a bit older and knew he was called to protect the Holy Virgin and the Messiah.