The time commitment is real, but on-site travel is almost always reserved for the last round on-site. Often as a final pass verification, or when the company is down to a couple of final candidates. Companies aren't flying every applicant out for all of the interviews. If you get to that point, you're close to the job.
Also, in terms of the costs to the applicants, this touches on the oligopolistic nature of so many industries today, which has resulted in high concentrations of the most desirable jobs in places with the highest costs of living.
Basically, unless you already have a FAANG job or are independently wealthy, it's not easy to up and move to Silicon Valley, Seattle, etc. and job hunt.