Exactly this.
Often it doesn't even require a sale. A lot of Facebook & Google advertising is for bullshit sites which push increasingly sketchy content backed by even sketchier advertising. Sometimes the goal isn't even profit, the Russians paid for advertising to influence politics.
If I an a potential buyer of, say, a book... and my interests include AI, multi-agent systems, and operating systems, then an ad for Barnes & Noble offering the new title OS Development for AI and Multi-Agent Systems is probably going to be mutually beneficial, because it will help me find a book I would want, and it helps B&N sell said book. OTOH, an ad for the new title Necrophilia And Cemetery Porn Of The Deep South is not beneficial to either party (if it's displayed to me) because it's not something I'd ever be remotely interested in. Frankly, I'd much prefer the (accurately) targeted ad.
If it resulted in a sale, then that means by definition it helped me find a product or service I wanted. If I made a bad decision in making that purchase, that's an orthogonal issue.
If the ad results in the viewer getting an eating disorder, for example, that's fine for the advertiser if it also results in a sale.