Basically they hook you up with fantastic financial aid. If you look up exit stats, Stanford students leave with one of the lowest debt levels of any med school. It is complex and personalized to every student, but they address this much better once a student is accepted and they crunch the numbers and do their magic in the financial aid office.
Almost everyone gets TAing money, and MedScholars research money after they start, as well, which can be quite generous. That money goes first to reducing the loan burden if you have loans (instead of reducing your direct financial aid).
The upper middle class income bracket has the most squeeze, as parents who make a decent amount of money, but are not super rich will get a decent sized bill, but I guess they factor in things like the number of other siblings in school, etc.
Many people find Stanford to be cheaper in practice than a state school.