I am trying to connect to my raspberry pi using either the hostname or IP address with ssh/a web browser/any internet application but it fails after a number of seconds with "Operation timed out" or "Connection Timed out".
What is wrong?
...it fails after a number of seconds with "Operation timed out" or "Connection Timed out".
There are two ways for that to happen:
There is no machine at the resolved IP address, although there is a known route which should reach it if it is online.
The machine at the address is using (or behind) a firewall that drops the packets. This is an unconventional thing for a firewall to do, because it creates more traffic for the machine running the firewall, since innocent applications will keep retrying until they time out. The normal way for a firewall to respond is with an ICMP packet saying the access is prohibited.
However, it is still something a firewall can do if someone configures it to do so.
Something which will not cause this is if the machine is reachable, but the SSH server isn't running. That will generate an immediate response from the operating system on the machine reported as "connection refused" by SSH clients.
Something which will not cause this is if the IP address or hostname is correct and the Pi is on the network but some piece of configuration is wrong.
Similarly, web browsers trying to connect to a machine with no web server running will immediately report a failure not a time out.
If this problem occurs within a LAN or via direct ethernet connection, you are using a normative Pi distribution such as Raspbian, and you have not configured a firewall on the Pi, then:
The machine you are using to reach the Pi has an unconventionally configured firewall, or
You are using the wrong IP address or hostname, or
The Pi is not connected to the network (which is the same as the last point, since it means there is no right address or hostname you could use).