It's common for Hack the Box machines to include web servers that respond differently to HTTP requests depending on if you're requesting the IP address directly, the hostname, or a sub-domain.
(This is called [virtual hosting](https://en.wikipedia.org/wiki/Virtual_hosting)).
For example, on the [Bucket](https://app.hackthebox.com/machines/Bucket) machine the webserver gives different responses for `http://10.10.10.212`, `http://bucket.htb`, and `http://s3.bucket.htb`.
There is no DNS service on the HTB network so you have to use your [hosts file](https://en.wikipedia.org/wiki/Hosts_(file)) to resolve host names into IP addresses.