A lie detector works based on two principles for it to have any chance of working:
1) The person must have a fear that his interrogators know more than their questions lead on. For example if you're asked "Where were you at 8pm on yesterday?" if you have a fear that your interrogator may already know the answer, and the honest answer may lead to something you're trying to hide. Your body will have a natural physiological and biological response to that fear, which the polygraph tries to pick up.
2) The person being questioned has to believe they are actually telling a lie. For example if you're asked "Did you intend to confront the person you followed?" If you honestly believe you did not intend to confront the person then the polygraph if working properly will not show a lie. However, just because you may not believe you did anything wrong you could have still committed a crime, law is not based on whether or not you believe you are violating a law but whether you're found to have violated it in a court of law.
Another example would be asking someone who recently killed another person, "Did you murder that person?" Well the person being questioned may pick up on the word murder and he may honestly believe that it was self defense and answer "No" and the polygraph will show no lie. However a court may later find that given the circumstances it actually was murder, in a legal sense, and not self defense.
Polygraphs are interesting tools but they are not fool proof, not 100% accurate, and subject to interpretation and subjectivity. To get results one must ask many many questions, time is a factor because like any analysis the more data one has the more accurate the analysis so a 20 minute interrogation would yield better results than a 4 minute interrogation. Plus polygraphs must be calibrated to each individual to see how their body signals react to the questions, that thing you see in the movies where they ask your name and date or birth is for calibration because they question they know the answer to.