This has happened to me twice on Canadian flights; the second time I asked one of the police officers what was going on, and they said they were looking for someone whom the flight manifest said was on board the plane. I suppose they could have come onto the plane to pull someone off, but that would have delayed everybody far more than checking ID on the way off.
I wouldn't want this to be a routine fishing expedition, but if there's someone specific they're looking for and they have a reason to think the person in question is on the plane, I really don't see any problem.