It's not about whether they can or can't. It's about the massive liability for the company if they fuck up on the job and cause property damage or bodily injury.
That could be true in a causative sense, but not a correlative* one. Not that it's ethical to do so, but by testing for marijuana smokers, businesses/insurance companies may by proxy be testing for other traits likely to cause accidents