The best-case scenario is that search engines work exactly as they're designed to, and that if you know how to ask, they'll give you exactly what you need. But as we know, of course, that doesn't always happen. When you don't speak the language, it's easy to get scammed.
Web search engines are created by companies, and companies have to pay their workers, which means they have to make money. How do they make money from offering search results? Through advertising, of course. Whether the necessity of advertising affects the integrity of your search results is a question that's frequently debated.
As [explained in that video], Google clearly delineates paid results from “real” search results, and they never accept money to alter search rankings. All reputable search engines draw that line. Still, you need to be aware that your search results are surrounded by advertising, and make sure you know where the one ends and the other begins. It's also important to remember that companies adopt those rules in part because web users demand them — which means that we have to be aware, and keep demanding them.
These ranking algorithms are impressive pieces of programming, but
they're not perfect, and they can be defeated. A company that
understands how these algorithms work can design its pages in a way
that helps the search engine find them index them correctly, and rank
them more highly.
Of course, that can be turned around. A company that understands how these indexes work can “game” the system to get its pages ranked more highly than others. Since the first search engines were built in the mid-1990s, there has been an ongoing arms race between search programmers trying to evaluate web pages objectively and publishers trying to make money by getting as many eyes as possible on their advertisements.
As this article from an industry website explains, there are lots of ways in which companies effectively pay for rankings. One of the most common is by buying and selling links — because more incoming links means a higher search ranking. Google has a strong policy against this practice, and they penalize publishers that do it, but they can't find all the violators. When there's money to be made, someone will try to game the system, and so the burden is on you to evaluate your search results carefully.
If you're interested in this topic, here are some directions to pursue: