Undoing some mod points to reply here, but anyway...
Aside from how dogs have been selected to "read man" (see the results of testing police dogs, where it was found most were alerting not on drugs, but on handler expectations), a dog's nose can pick up even the slightest difference in a person's metabolism -- half a dozen molecules are sufficient for some dogs' noses to distinguish. In crude terms, when there's something "wrong" with the human's chemistry, which includes brain chemistry, they smell different from other folks (probably due to the metabolic byproducts being different). If that smells "wrong" to the dog, they're going to react against it, often with fear or aggression.
This is also why some assistance dogs alert to their owner's health status -- I know a guy whose dog goes nuts if he's starting a diabetic episode, and he's learned (the hard way) the dog is right even tho he hasn't any symptoms yet. He starts smelling wrong to her, so she throws a fit, and she notices well before the blood test does. (He's done multiple tests in a row to check against her reaction.)
Incidentally I have a dog who 'alerts' on certain abnormal personalities -- he's naturally trusting and loves everyone else, but acts like he wants to kill a very few individuals: One was a paranoid schizophrenic (among other symptoms, she heard voices and saw things that weren't there), another had bipolar disorder with severe anger issues, and so on. And this dog, who has an exceptional nose, visibly does the "take a sniff, then react" thing. I've learned that when this dog doesn't like someone, I had better pay attention, because he's always right.
[I'm a pro dog trainer with over 40 years experience. I notice these things.]