In the case of Brexit, the sudden swing to 'leave' happened very shortly after leave ran a massive campaign of deceptive dark ads on Facebook. This advertising campaign pushed factually untrue narratives (such as that the EU was on the verge of forcing the UK to be overrun by Syrian migrants)[1] to vulnerable people and, from all indications was able to turn the referendum in leave's favor.
The sudden swing towards leave does not seem to represent a failure in polling (or media) but rather a demonstration that Facebook's dark ads platform alone can subvert the ability of a high-functioning democracy to make an informed, fact-based, decision on a question that will impact generations of people.
That should terrify a lot more people than it does.
[1] https://www.joe.co.uk/news/brexit-facebook-adverts-192164 ;
https://www.channel4.com/news/factcheck/factcheck-vote-leave...