I think the most likely explanation is that “the brethren of the Lord” are siblings through a previous marriage of Joseph, cousins, or a combination of both. In the protoevanglium of James, eventhough it is not scripture, it talks about how at the time of his marriage to Mary Joseph was considerably older than her (which had made him anxious about the marriage to begin with) and that he was a widower with children. So this theory would make sense considering the mentioning of the brethren of Jesus, and the fact that Joseph is presumed to have died in or around Jesus’ teenage years perhaps due to his old age. This would also make sense in light of the fact that Jesus handed the care of Mary over to St. John because Jesus’ step siblings were probably considerably older than Jesus and had families of their own to take care of and even they may not even have been living in the Jerusalem area anyways so John was probably the best candidate to take care of her.