Well yeah, Google tried to build a social network (actually several) and failed; Facebook didn't try to build a search engine - that wouldn't fit into their business model of sucking you in and driving you to sign up to Facebook. I mean, after they bought Oculus, they even started requiring a FB account to use the device, but they couldn't have done that for a search engine, nobody would have used it. But lots of others did, and failed (or at least couldn't compete with Google).
So we can conclude that neither building a successful social network nor building a successful search engine is easy :)
but fb does have a search engine? Admittedly it only searches for content on their own site, but as you note the strategy has been to make the walled garden so expansive that users would never want to leave (or be able to --- see India). Building a general purpose web search engine would be to give up on the "own everything" strategy.
Yet Google tries really hard to get you to log in, to the point where if you log into the browser to be able to sync your bookmarks and settings, you will be logged into your Google search as well.