what happens to the data when a user submits a login form to a PHP script on server?
The data travels over the internet from one computer to another. Nothing more, nothing less. What the server does with the submitted data is up to the server.
Why we hash or encrypt the password on the server side...
In order not to store the password in plain text where anybody can see it. A password is a secret that only the user should know and nobody else. Yes, it needs to travel to the server in plain form, this is more or less inevitable. But then the server should do everything in its power to not leave any trace of this plain form around.
...can be read by any hacker.
That's why every data submission should be secured by a SSL/TLS connection. Without that, it's indeed just plaintext on the wire. A properly set up TLS connection in a secure environment is practically unbreakable.