The same exact undertones that drive Trump's support in the US (and to a lesser extent Sanders) were what drove the Brexit movement. Many of these people don't even understand the EU, they just want to give the finger to everyone who happened to be on the Remain side.
The vast majority of people who voted for it were older, so won't have to live with the consequences, or working class who outright rejected the arguments of experts/academics/etc. This was a "my heartfelt ignorance is just as valid as your knowledge" situation.
So, yes, 500K more people voted for Brexit than voted to Remain. But what is it that they actually were voting for? If you listen to them talk or look at surveys, it had little to do with the EU beyond immigration.
Want to know something darkly amusing? It's possible that they didn't. This is still anecdotal at this point, and of course the Remain side could be playing it up, but there are reports that at least some Leave voters intended it as a protest vote thinking it wouldn't actually happen: https://twitter.com/AdamWSweeney/status/746261907233988609
How wonderful would that be, if the biggest blunder in Britain's history happened unintentionally because some people wanted to stick it to their council. I need to go drink some more.