Those entries force those hostnames to all resolve to the corresponding IP address. So whenever the system tries to reach those hostnames (ie to retrieve an ad), it makes a request to that IP address and receives a 404 error. So no ads.
If the system tries to reach a host not listed in the hosts file, it goes to DNS for resolution (and should get a real IP address).
So if you want to see a specific ad, you can delete it's corresponding entry from the hosts file. Or if you want all the ads, delete everything below the 127.0.0.1 entry.