The same principles that let you work in other countries allow foreign pilots to work in Canada where the standards are sometimes less than they are in other countries each of whom will swear that their standards are the best.
Pilots are human beings and odds are out of a 1,000 drivers on the road at any time, there will be a handful on the road impaired.
The number of pilots that actually get caught impaired is only a fraction of those who fly impaired and are never caught, unless of course, you are so drunk that its obvious to anyone and everyone, forgetting of course the security in Indonesia that let an obviously impaired pilot who staggered past security.