That’s because the whole phrase, which is almost never used anymore because of its implications, is "One bad apple spoils the barrel. If you have one bad cop, the others will cover for him, as will the union, rendering every cop in that “barrel” bad. Every cop belonging to the local union, and the national union, who doesn’t protest at being forced to join such a corrupt organization as a requirement for their job becomes tainted and therefore bad.
Its not that they can’t do good things, I’m sure their mothers love them and that they think of themselves as good people. But when you find a bad apple, you don’t put it in the barrel in the first place, and if you do find a bad apple in there, you pull it out of the barrel and then examine all the rest for any hint of rot, and throw them out as well. Any other behavior results in a barrel of rot and corruption.
Proclaiming ACAB and calling for defunding the police are not attacks on the institution of law and order, but an immune response on the part of the populace attacking the corruption in the body politic.