Th 'Twin" belief is not a late tradition but rather apparently actually predates the writing, or at least distribution, of the 4 canonical Gospels. Not surprisingly many, many traditions circulated around the Jesus figure. The church Fathers themselves repeated stories that are not only not in the 4 Gospels (later Canonized) but contradicting them. Pious mythmaking was endemic for hundreds of years, in fact never ended. (e.g. Book of Mormon) The Gospels themselves differ regarding Jesus having brothers due to active 'enhancement' and editing to refute Adoptionism (Jesus the man was adopted by God) and Docetism (Jesus was merely a spirit appearing to be a man) . Ironically, the idea that Jesus had brother named Judas (aka, Didymus the Twin) was useful for refuting the Docetists but leant to the Adoptionists' argument that Jeus birth was not miraculous. The solution may well have been to make the identification of Didymus and Judas obscure in the forms of the Gospel that the Proto-Orthodoxy had massaged.
In other words, that Jesus had a twin brother was believed in some circles for many years. The 4 canonical Gospels were not the only pious stories. There were earlier versions and later ones.