Take a look through these threads for explanations on the many, many ways last names came about around the world:
Where did surnames come from? by /u/potterarchy and /u/snackburros, among others
When did tradition of having a first-name and a surname come from? Was there a time when people only had one name? by /u/LadyOfTheLabyrinth
Around what time period did last names become commonplace? by /u/AldusManutius
If you're interested in last names in general, check out the subreddit search results for "surname" and "last name".