There are a lot of "Mexican" things in the US that aren't really Mexican - or which developed in border areas for the benefit of richer clients. Much of Mexican food is this way.
I just spent a few minutes poking around the internet for stories about where this phrase came from. It's not a common Mexican phrase. The stories I found ranged from poor workers living in houses that belonged to their rich Spanish overlord, to indigenous people thinking that the Spanish settlers were gods, or to simple explanations stemming from Mexican hospitality. Right or wrong, it's this last notion which lives on in the conventional thinking today.
I'm persuaded by the following, more practical explanation. We Americans wanted to invent a fancy-sounding foreign phrase to use when we're welcoming people into our homes, and "mi casa es tu casa" is much easier to say than the Welsh alternative: 'Fy nghartref yw dy gartref'.
"Mi casa es tu casa" is a Spanish idiom that's become widely known in the English-speaking world. Its meaning is exactly the same as, "Mia hejmo estas via hejmo."
Part of learning Esperanto, as with any other language, is finding relevance to what one already knows. For most people, it's far easier to remember something if we can attach it to something else: for example, Ĉu ne? = Nicht wahr? = N'cest pas?