why is Editing Hosts file for redirecting to IP of my choice giving a 404 error

Your modification did push you to 172.217.174.228, the 404 error page you got is from Google. There's a message:

The requested URL / was not found on this server.

This is how it looks in my Firefox:

404 error page in Firefox

The server checked the URL you used, trying to decide what website it should serve. There can be many websites behind a single IP address and the URL tells the server which one you want.

In this case the server does not recognize adaway.org as any website it can show you, hence the error.

Additionally the server cannot authenticate with the certificate for adaway.org. It's not genuine adaway.org, it does not have their certificate. My Firefox tells me Connection is not secure but still lets me see what the server returned. Other browsers (with other settings) may refuse to talk to the fraudulent server. My Vivaldi is set up to be more careful; this is what I get in Vivaldi:

warning from Vivaldi

This server could not prove that it is adaway.org; its security certificate is from www.google.com. This may be caused by a misconfiguration or an attacker intercepting your connection.

As you can see it's not enough to redirect to another IP address only. You need to make your browser use URL the server recognizes as its own (ideally: recognizes and can authenticate), or at least translate communication on the fly, so the server sees URLs different from what your browser requests. You cannot do this solely by modifying the hosts file.