That's actually a pretty accurate description of what doctors have to do, at least in the UK. For the first nine years after finishing medical school, doctors have to take a series of exams, including written exams and practical tests, which are primarily diagnosing and proposing treatments for real ("mystery") patients. This is a centralised process, rather than ad-hoc tests at every interview, but doctors do have to continue demonstrating their competence during their careers.
Or is it mainly based on who they know and who recommends them?
Would be interesting to consider if it's possible to administer a whiteboarding exam on programmers once, and then consider them solid on the concepts tested if they pass. And if not, then why? Does that mean whiteboarding as it is practiced now is insufficient? Because it certainly seems like for engineers who switch jobs every 2-5 years, they have to be whiteboarded again even if they've had prior experience, even at larger corporations known for rigorous interview practices.
It's as if this industry lacks confidence in its own employment standards, unlike the medical, legal, and other accredited fields.
It may also be the fact that doctoring is more about keeping a large amount of facts and experiences in mind as condensed expertise, while programming is more about raw intelligence and solving novel problems analytically (although this sounds a bit pretentious and self-important, I know). Cardiology is very unlike logic puzzles. Now sure, day-to-day programming may also not be much like logic puzzles, hence the endless criticism of whiteboard leetcode interviews.
Depends which border they cross. Then there's a lot of red tape and regulation by the local cartel to deal with.