If you put server names into your Hosts file with your own computer's IP address, your computer will never be able to contact the server. It will try to, but it will be simply calling itself and get a "busy signal" of sorts. Your computer will then give up calling the server and nothing will be loaded, nor will any tracking take place. Your choices for blocking sites are not just limited to blocking servers. You may block sites that serve advertisements, sites that serve objectionable content, or any other site that you choose to block.
Computers have a host address of their own - it is known as the "localhost" address, with an IP address of 127.0.0.1 which it uses to refer to itself. If you associate another computer's host name with your localhost IP address, you have effectively blocked that host since all attempts to access it will lead back to you. That is how we will block sites using the Hosts file. We will tell our computer that the IP address of the site we want to block is our own address. That way, our computer will not ever leave and go looking for the site we are blocking - which keeps that site from appearing because the computer thinks it has found the site and displayed it already.
There are some limitations though such as,
1. It will not work with wildcards, such as