Law enforcement people get on tears about some things, and as they spend all of their time dealing with crooks, they tend to assume that everyone is a crook. It is best to stay away from them.
Yep, the biggest liars are the guilty so it is easy for them to just assume you are both.
I used to be, and still am to some extent, a strong supporter of LE and prosecutors. Having been railroaded on some penny ante stuff, traffic tickets, and being familiar with some other cases I was not involved in, I know that cops do lie and prosecutors do aid and abet them. That degrades their reputations for all of us.
As you said, stay away. When you can't, be polite and don't antagonize. That is not fool proof but it is still the best.