Regarding the sniffer dogs...
You'd be astounded what they can actually smell (especially a breed like beagles), edibles sealed in a bag might not be dog proof.
Also if the state/local PD are taking a dog through the terminal, it *might* be trained for explosives, but it might also be trained for drugs.
Or it might just be a drug dog, local LE is 100% within their rights to take a drug dog through the terminals, which are almost always owned by local/state governments. They probably do that to try to catch traffickers with large quantities, but if you get caught with personal use stuff they can certainly take you in for that if it's a slow day.
And if you look like a dirty, nasty hippy... the dogs are pretty attuned to their handlers, if the handler thinks you might have drugs dogs will often pick up on that and alert just to make the handler happy. I'm OK with dogs for bombs, not so much for drugs honestly due to known reliability issues.