Players have agents. Agent's job is to sell players for teams. I believe they create kind of profiles for their players and if there's a team looking for lets say a center with good defensive abilities, they can sugest someone suitable for that spot. If both team and player agree on contract issues it's done. Ofc there's a lot of background checking aswell.