
In order to do that Google uses an algorithm to rank websites, extract keywoeds and display search results, and it takes into account many factors like the ones in the previous paragraph. More, Google personalizes the search results based on each user's individual search history and their previous interactions, and that means the results in different results for the same keyword may be different. This means that people searching for the same term on Google may get slightly different results based on all those factors.
Probably the other search engines do something similar or very similar, only their algorithms differ and people chose in many situations Google as their search engines.