SAN FRANCISCO—Lucho Cabrera, a 53-year-old formerly homeless man, turned to an unlikely place during his recent hunt for affordable housing: a $3 million community center built by Twitter Inc. across from the social media giant’s sleek art deco headquarters.

The NeighborNest center exists because the city five years ago struck deals with tech companies to move to the gritty Tenderloin area in exchange for tax breaks particularly attractive to start-ups. Twitter, Zendesk, Spotify and others snapped up new headquarters buildings,...