indexes sites that that had been forwarded to it. or that it knows about. it also searches meta data which is inaccurate (i.e it looks at the pages that have all those words like titshornybitchescumanalcunt.

google employs a technology called spidering. The pages that come up highest in a result are those that other websites refer to. So google starts with one page, then its spiders look up the links on that pages and jumps to it..building a massive dynamic database.