The drugs you took outside your work hours don't know they have to exit your bloodstream the hour you start working. Perhaps not all occupations need such tests, but at least people driving vehicles and operating heavy equipment should be made sure to have their system clear while at work.
The tests usually don't have granularity to know if you're intoxicated during work hours precisely. Most test for metabolites that either aren't intoxicating or intoxicating in far higher levels than detection cutoff.