First, a search engine "crawls" the web. It does this by going to websites and clicking links within the websites and then clicking links in those websites, etc. The search engine then creates an index. Any website that has the word "fossil" in it is added to the index under "fossil." So if you search for the word "fossil," the search engine just has to look in their index to get a list of websites with the word fossil in them.
That was pretty much it until the late 90's when Google came out with the Pagerank algorithm (named after Larry Page, not the term webpage). Google counts the number of links to a web page and determines to determine their "importance." Does every website talking about fossils like to the wikipedia page? Better make that the #1 search response. There are other tricks, too. Does everybody click on the 2nd link? Make that the first one.