The vast majority of international MIT students are graduate students. Except for business students (i.e. MBA, executive MBA and similar), graduate students in research programs do not pay a dime to MIT. Their tuition + stipend for living expenses is paid by research or TA fellowships. I.e. they either work as either research or teaching assistants to receive this money. MIT receives part of the fellowship money as an "overhead" tax, but this is exactly what happens for domestic graduate students.
Notably, in the case of MIT these fellowships are provided to both M.S. and PhD students. I believe that Stanford M.S. students do not get such fellowships and hence need to pay for their tuition.
Source: got my PhD at MIT as an international F1 student.
That’s just direct economic analysis. Graduate students are incredibly valuable to the universities because they generate research which can be used to either directly apply for grants and federal/commercial awards, or which can be used to just add to the university’s reputation (which, in turn, affects their chances of getting a grant or money award, as they have a reputation of expertise). Even if the direct money being paid by these students is zero, I’m sure all universities (not just MIT and Harvard) care deeply about where their graduate students go; that’s a lot of good grey matter going to waste, and universities are in the business of converting grey matter directly into money!
Source: got my PhD at MIT as an international F1 student.