These direct democracy votes often turn out this way - the people vote on a topic differently than how they vote for representatives. But a large portion of why we don't practice direct democracy in most of the west is because you don't want a mob of opinions dictating national law.
It isn't undemocratic for democratically elected representatives to go against a referendum. They were elected to rule on behalf of their people, even if that is in contradiction to non-binding votes by said people. Its their reelection funeral if they go against popular opinion and turn out wrong, but its their job to do it if they think its right. Its why we have representatives in the first place!
The problem here is that they went ahead and voted for it, without actually doing the hard work of drafting a concrete proposal for how Brexit will happen.
Governments do this all the time, though. Campaign promises are often just that.