Google spends all day every day searching the web with bots.  Websites are cataloged in a database and when you search, it’s the database that is being looked through, not the whole Internet.  Lots of sites like internal corporate websites prevent Google from being able to read them for their database so you’re actually not seeing all of the internet.

When you search the web using Google, you’re actually searching a slightly old database of the web on Google’s servers.  To deliver results quickly Google uses “sharding” which means it uses thousands of computers each working in parallel responsible for a small part of the database.  Your google search is fed to many different computers and the results are merged and returned to you in seconds.

Here’s an easy to understand graphic from Google called “How Search Works”