I'm not on LinkedIn, but On Facebook I think it works a variety of ways:

Based on any information you enter into your profile (city of birth, city of residence, schools, employment, hobby, friends etc) they'l start to suggest people who went to your school, live in your town, are friends of your friends, work at your place of employment etc

On Facebook if somebody names you in a post, you probably get suggestions for that person and all of their friends

The suggestions facebook has made to me seem to be related to the qualifiers I mention plus a few more I haven't figured out yet