Let's assume for sake of argument that Mary was born into the tribe of Judah (a reasonable assumption but it depends on additional questions--did Matthew/Luke record the genealogy of Joseph or of Mary? Many have concluded that one records Joseph's genealogy and the other records Mary's, in which case Mary would be born into the tribe of Judah)
Because people from different tribes intermarried, a person's tribe was determined by patrilineal descent (their father's father's father etc. -- see Numbers 36:7). It is highly probable that more than a millennium and a half after Jacob, all Jews were descendants of multiple sons of Jacob.
The text does not give Mary or Elizabeth's matrilineal line, but the simplest explanations are:
- Mary's mother was of the tribe of Levi OR
- Elizabeth's mother was of the tribe of Judah
There are numerous other possible permutations, but there's nothing at all improbable about John & Jesus being related.
Judah and Levi were probably both common ancestors to Elizabeth & Mary--it is statistically very improbable that they were not--but in keeping with Jewish custom the text records only their patrilineal genealogy. Mary's father was of the tribe of Judah and Elizabeth's father was of the tribe of Levi.