You're probably thinking about pre-election polls. Those are frequently off by a few percentage points even if they took great care to take a large representative sample of the population because it's difficult to predict turnout. However, there's one opportunity to get a representative sample of voters: by conducting an exit poll right after they voted. If exit polls show a large discrepancy from actual results, it's usually seen as an indicator of fraud.