When you enter localhost in your browser, your browser looks into the hosts file, obtains the specified IP address, and takes you to that IP address. The above two parts, when combined together, redirect all the localhost queries to the IP address 127.0.0.1. The second section where it has the host name is what you use to access that IP address.
The first section with numbers is the local IP address for your Mac.