Google started as a search engine and ad company, and has since reinvented itself with investment in new areas like photos, email, Android, etc.
There’s really no point in comparing Google to Yahoo. Google actually developed a solid strategy fairly early on, which involved (1) collecting data from any source possible (all their services are designed around collecting data), (2) selling that data to advertisers, and (3) (very important) creating and owning platforms (Android, Chrome, Youtube, Pixel, GCP etc.) that allow them to not depend on anybody else.
There’s really no point in comparing Google to Yahoo. Google actually developed a solid strategy fairly early on, which involved (1) collecting data from any source possible (all their services are designed around collecting data), (2) selling that data to advertisers, and (3) (very important) creating and owning platforms (Android, Chrome, Youtube, Pixel, GCP etc.) that allow them to not depend on anybody else.