So why do these companies insist on these incredibly long hiring processes? Clearly it must not be working if candidates are moving on before they're hired.
They don't insist on it. It's just the way they operate.
Everything takes ages in the corporate world. Every hiring decision needs to be signed off by interviewers, managers, HR, and sometimes even executives. Someone in this chain is usually on vacation, but there's no clear replacement, so someone else needs to be brought up to speed. Meetings need to take place for everyone to touch base, and discuss the candidates. Coordinating this around everyone's availability is difficult, since they have other meetings to attend. It really takes some outside-the-box thinking to make it happen. :)
Also, depending on the size and popularity of the company, they might be evaluating dozens of candidates at the same time. This also clogs the pipeline considerably.
But not everywhere. I've been hired by a couple of major tech companies and didn't have to go through such an insane, lengthy process as this. I think a lot of it depends on the corporate culture.
My assumption is that they do it to select for the types of employees that will put up with nonsense. I know that sounds like I'm being flip, but I'm not.
There are tons of companies that don't do this (at least in the US), though, so there's no real reason to put up with it.