No, that’s because websites are named based. That means: When you goto www.domain.com, your browser tells the webserver you want www.domain.com. The webserver then looks through it’s configs for “www.domain.com” and pulls up the approrpriate pages. Going directly to the IP sends the IP address and web server does not know what site to pull up. So you get a default config (or one that’s been assigned directly to that IP address).
There’s more than one domain on a single ip address which is why the named based hosting is required. It minimizes the required IP pool to allow more domain hosting. If it wasn’t for named based hosting, half these sites on the net wouldn’t exsist.
Just a hint; there are more websites on the internet than there are IPv4 IP addresses.
When you add it to your hosts file, you tell your browser what IP to use for the domain so your browser can correctly connect to the right server AND send across the domain name in it’s request.