... To put it mildly: it is not guaranteed that if you're flown out you will get an offer.
..., and you replace the onsite with even an excessively long project, that's a win. The project can be written at the candidate's own pace and schedules conveniently around their other obligations. They do not have to arrange child care, take off time from work, or make tradeoffs like "Do I do the project or do I attend a friend's wedding?"
All true but my observation is that the companies that put candidates through multi-day-out-of-town interview processes can afford to miss out on the candidates that can't do it. Tellingly, the type of companies like Google and Microsoft that put a lot of burden on candidates hire heavily from a pipeline of fresh college graduates. Not surprisingly, a lot of 22-year olds don't have existing jobs or kids they have to juggle to commit to intensive interview processes. Sure, they also interview older middle-aged candidates but the benchmark tolerance for hoop-jumping is set by the 22-year olds therefore you won't get sympathy from employers about disrupting your life to stay in the running. For those companies, even if they are flying you out, you're still in the "evaluation" stage and could be 50/50 accept/reject.
Contrast that with boutique consulting firms that hire from the 30+ age bracket (often by poaching other consulting firms' employees.) A lot of their candidates already have existing (lucrative) jobs. Most of their evaluation is done on multiple phone interviews. If the company decides to fly you to their headquarters to interview, you basically have the job unless you unzip your pants and urinate on the interviewer's desk. The onsite interview is not a technical screening but a personality sanity check. At that stage, you're 90/10 accept/reject.