Facebook is based on networks. For example, I am currently in the University of Massachusetts network and Nassau County network. So, I can only see people's profiles if they are in my schools network or nassau county network. Also, there's an option to only allow people to see your profile if they are friends with you, so I can't see Joe Shmo's profile because he has that setting turned on, all I see is his picture and a dead link when I search his name. The only way I can see someone's profile who is not in my network is to be friends with them.
You can also make it so certain people don't even know you exist on facebook, they will search your name and nothing will come up. You can block your boss, your RA if you go to college, or a stalker, etc. etc. It's all in the privacy settings.