Sometimes, they know that a crime was committed but can't go after the person without jeopardizing other people, so they have to find another way to get to the evidence they know is there, but unfortunately, that involves the illusion of violating civil liberties; after all, what other explanation do they have for how they found out? This sometimes creates the need for some wrongful creativity. For instance, the bad guy has something in his house, but they can't just go in without probable cause or else it'll be thrown out, so they told their friendly neighborhood burglar when to break in and should anything happen, they'll have his back. He breaks in, prompting legitimate reason to investigate. Bingo, police got lucky and found what they secretly knew was there, but now the process (the how it was found) is legitimate.
The detective never used his creativity to circumvent the basis of how and chose instead to hide behind the non-disclosure. It could have backfired if not for the prosecution. What makes me curious is why the judge wasn't let in on it. Don't they realize they're not out to violate liberties? They just want to put the bad guys away.