I do not intend to go into this subject in any depth - as there are many books on the subject. However it is possibly worth giving a simple example of the kind of thing that was happening in early medieval times.
Let us assume that there were two people called John living in a small community called Betlow. Within the community there would need to be some way of distinguishing between them so one John may have been John the smith, or John Redbeard, or John who lived in the White House, while the other might have been John William's son, or John Little, or John Scrivener (because he was the only person in the village who could write). The first John was one of two smiths which served an adjoining community - and as he was the best he was known there as John good enough. The second John often went to a town a few miles away where he was known as John of Betlow.
This was OK when everyone was quite clear who you were talking about - but there was considerable grounds for confusion, and eventually one of the epithets would become permanently associated with the individual - and not only that - it got passed on to his children and a surname was born.
There are many reasons to be cautious:
It is pretty obvious that there would be smiths in virtually every community and that the fact that two people have the surname Smith does not mean that they have a common Smith ancestor. For the same reason two people with the surname Betlow may not have a common Betlow ancestor.
The spelling and pronunciation of many words (including surnames and placenames) have drifted significantly over the centuries - so the current spelling may not be a good indicator of its origins.
The origins given for many names in books of surnames (and placenames) origins are often no more than intelligent guesses.
To give an example - I have extensively researched the Phipson family. This is given in some books as "Son of Phipps" - or in effect "Son of Son of Phillip" and this may be true. However most of the oldest references come from the West Midlands - where there is a manor of Phipsen. I wonder ...
However I have also come across a case where someone called "Fitz Penn" meaning "Son of Penn" was recorded as "Phipson" - so this gives another possibility, which I think is less likely.