This was mainly based on privately conducted measuring (e.g. exit polls, and other ways to sense the poll, such as turnout measures, where high turnout was thought to favor remain). Such polls would be undertaken largely for the hedge funds looking to profit from their privetly collected information (... while no exit polls can be 'published' before the results that doesn't stop people conducting their own, and trading on the results).
Any trading by hedge funds, will then start to sway the markets and betting odds, so even if the don't publish their expectations, you can start to see which way their polls were predicting. Sterling rose a bit after the polls closed, and betting reached about 88% likelihood of remain on Bet Fair. This in-line with Nigel Farage indicating towards the start of the evening that he thought Remain had won.
Obviously, these indications can be wrong: the proxies such as 'high turnout', thought to favor remain, evidently didn't play the way people were expecting.
In addition, it's likely that a lot of the evidently 'over-confidence' in the remain side comes from people reacting to each other's confidence: as the betting market rose, and Sterling rose, it gives confidence to the remain side that they had won. ... i nearly put a few thousand dollars on remain thinking at the peak point, thinking that given all the indicators, it was a certainty. Behavior like that pushes it up further, and encourages more to 'think' it must be remain.