Awhile back I had a LEO in the ER with a K-9 bite, I didn’t get details, but he said it was more common than you might think.
Does seem to be a problem some places, but usually a separate issue from whether the police’s own dogs are well enough trained. Not always separate though since at least some of these incidents happen when ‘civilian’ dogs attack K9’s (which are, from the ‘civilian’ dog POV, simply strange dogs invading their territory), then police protect the K9 by shooting the other dog.
Nothing like that has happened where I live that I’ve heard of. But I can recall K9’s on our local police force not well enough trained at least to ignore my (late) dog, which seems to me they should be (though no expert on training dogs). They would try to intimidate her with growling etc. which just set off her hyper-aggression (a rescue from a fighting breeder, genuine bad ass to other dogs, though a cream puff to people). Nothing bad happened with both dogs on leash, but if either were off leash it could have resulted in a dead K9 or my dog getting shot.
The issue is that if the dog is working, it’s not petting time; this applies to any kind of working dog or for that matter working animal. Most people wouldn’t try to hug random working people but see no problem with trying to pet a working dog or horse. Work time <> petting time.
Petting that same dog when it’s off-duty is not any more of a problem than for any other dog.