Exit polls = After voting
Polling = Before voting.
There are many methods and approaches to generating the sample (group of people) for the polls.
Bear in mind the samples are very small. think of a few thousand, so your chance of being polled, 2000 out of 40+ million) is very small, even if it was entirely random.
In terms of how they reach people, it used to be on the street or by phone (it still is in some cases) but now it is mostly online, done by asking people to sign up to a polling organization.
Then instead of being the more traditional random sampling method, now it is mostly stratified (quota) sampling, where they basically try and construct a small group, that represents the bigger group.
So for example, in their 2000 people, they want the same % of men, of women, of ages, of ethnicities, of wealth, of regions etc. or whatever metric they think impacts voting.
If done correctly you end up with a small sample that is mostly representative of the general population, and the vote given by the smaller group, matches what the bigger group will do.
To make it even more accurate, pollsters/news agencies will then accumilate lots of these polls, and average them out (removing outliers) to create an overall bigger aggregate poll.
There are obvious times where this goes wrong (Brexit, 2016 election, trump v1 etc.) but overall, over the past half a century stratified/quota based polls have proved very accurate and the statistics and methods behind them are solid.