The answer, unequivocally, is yes. More precisely, they operate under different sections of the same laws that you and I do.
Police conducting undercover operations frequently break the law. For example, they might bribe someone, or pay money for stolen goods. They may even use illegal drugs.