Well when a butt head cops says "XYZ" is illegal. Now who has one. And the rest pull one out to show him. You pretty much get what you deserve.
Here, the person claiming to be a cop told the rider that the knife was illegal. The correct response was "thank you, officer." It went wrong when the rider "admitted" to the "crime," informed the "officer" that they regularly disregard that "law" and informed the officer that "everyone" - including the other friends present - were guilty of the same infraction both then and on a regular basis.
If this was truly a crime worth prosecuting and the "officer" was so inclined, he had a guaranteed conviction. The original knife was out in the open and a full confession was received. Probably cause to justify a search of everyone else there was created when the first person (and others) admitted they also broke the "law."
The same rule applies to everyone, whether or not this guy was really a cop. Some person approaches you with the obvious intention of ruining your day, don't have a conversation, don't explain yourself - simply shut your mouth and walk away. Nothing good will come from arguing your point, especially if the other person really is a cop.