If the like button is hosted on Facebook, your browser requests it from there when you visit the page. So the site doesn't have to do anything except include an img tag with a Facebook url in it; everything else is a consequence of how the internet works.
Google Analytics creates the same problem. This is why I use server side analytics instead. I don't want to send a list of everybody who visits my website to Google.