Kind of, but it's not like you're forced to do it - you complying just means that you value getting the job more than the small invasion into your privacy. It's just a private agreement, not one that can land you in jail as far as I know.
I think the employer has two interests in checking on this. The first is that they don't want you wasted at work, and drugs may mean you would perform badly even when not high. If I knew someone was a crack head I wouldn't hire them simply because crack greatly affects your ability to function even when you aren't high. That said, I'd probably still hire someone doing pot because it isn't as debelitating when you are off your high. The second reason is probably that if you are doing illegal drugs there is a chance you will get busted and go to jail, meaning an employer will suddenly and unexpectedly be without an employee. Most employers probably don't want to take on that risk.
Still, if you do drugs and you want to not get caught in the interview process just don't do them for a month or so before doing interviews. Unless you start behaving strangely afterwards it's not likely they'll ask you to take a test again once they've hired you.
Makes sense...as long as it is kept confidential.