This is only true if people's want for it exceeds their want to not break the law.
For illegal drugs, people who want them want them a lot, so them being illegal isn't a strong deterrent; although, legalization has still absolutely increased the number of users (i.e. legality was acting as an effective deterrent for some.)
For illegal gambling, sure _some_ people won't be deterred by legality, but most people aren't hardcore gambling addicts; they're just engaging as a form of "harmless fun." They're not looking to go to jail to toss $20 on a sports game.