In the same way statistical spam filters are junk† science. They suffer from false positives/negatives issues, but they perform a lot better than coin toss.
They're based on the idea that if you're made to tell a lie, your body will react in some way (sweating, faster heartbeat etc) compared to a baseline measurement. There is a whole field of psychology around lying and additionally agents are ostensibly trained to detect visual cues that someone is telling a lie.
The premise isn't exactly junk - hardware lie detectors are basically trying to identify a fight or flight reaction, which some people will exhibit when lying. Have you ever been confronted with a fact (did you eat that cookie?), lied, and felt a rush or a feeling of panic? That's what lie detectors try to detect.
The problem is it's possible to fool a polygraph and it's prone to bias. For example some people get nervous when asked a question, even if innocent. It's theatre in some sense, and it shouldn't be assumed as 100% accurate, but there are plenty of people who will break out into a cold sweat when you ask them a question they don't want to answer truthfully.
I wouldn't disagree with that. And a big problem is that innocent people tend to produce stress reactions when interrogated, leading to false positives. It would be appropriate to call a polygraph a "fear" detector, since that's basically what it's measuring. But still, the "science" isn't entirely bunk: some people do panic when they lie - though I read an anecdote that said this is a weirdly American trait (Europeans can cheat the polygraph more easily) - but it's virtually impossible to sift out the true positives from the noise.