What should be illegal and what is actually illegal under the Patriot Act and Five Eyes are vastly different things.
Just because the methods used to track him infringe on our privacy and rights doesn't mean the weapon was necessarily planted, he could've been planning a second attack or simply wanted to be caught.