There you go: assuming the analysis of leave voters was not sound.
Many voters made a very straightforward analysis: "the EU means I compete against an essentially infinite supply of labour, I can't do that, therefore we should get out of the EU so we can restrict immigration again".
You may not agree with this reasoning or you may feel the various other benefits of the EU outweigh them in your personal circumstances, but it's not an illogical analysis: they think leaving will make them economically better off and there are millions of such voters. It's actually quite difficult to mount a robust economic argument against this idea: you have to argue that the EU will erect such serious trade barriers that all the jobs disappear. But a lot of these people are working in local service industries anyway, they aren't selling to the EU, so you end up arguing a very indirect path to them personally suffering which basically rests on "the EU will be such bastards that the entire UK economy collapses", which then stirs up patriotic sentiments very strongly (reminds people of the war). And you rapidly end up in economic wonk territory because the details of the damage depend so much on details of the final deal, etc. The public, quite rightly, does not trust economists due to their track record of getting the big things wrong.
The economic rationale for Scotland leaving the UK and joining the EU is much less clear. The big one is public spending. The Scots may not like it but their country is subsidised by the UK to a huge degree. The spending deficit alone is the same size as ALL Scottish NHS spending. The economic argument from "lose the subsidies from the English, public services are cut because oil is cheap" is very direct and much more easily understood. Scotland does not have a problem with massive immigration. People like the idea of the EU but what specific economic problem would it solve for them?