Without my Switch with me, I don't know the exact steps, but you go to the home screen on your Switch, then hit your profile icon in the top left corner. Once your profile opens, on the left there is a series of menu options, one of which deals with adding friends. You just need to find the add a friend option that involves entering friend codes, which are a series of numbers like this 1234-5678-9012. The SW part you may typically see others put in front of their code signifies that the code belongs to the Switch, and not the Wii, NDS, or 3DS. So you don't need to do anything with it.
There is an option in the game for playing with people without adding them to your friend list if you'd like that. This involves using what's called a Dodo code, which the Airport in game can explain to you.