A lie detector (polygraph) is a device that measures physical conditions like breathing rate, pulse, blood pressure and perspiration as indicators of emotional levels. The operator will ask a lot of insignificant questions before popping the critical question. A person that's lying knows the critical question is coming and builds suspense. A person telling the truth doesn't have that fear.
If the subject person is nervous throughout the test, that will not be seen as deception. It's the difference in emotional levels between the insignificant and the critical questions that indicate deception.
The accuracy greatly depends on the skills of the operator at both asking the questions and reading the data collected during the test.