SAN JOSE, Calif.—Technology giants helped pump the West Coast full of choking traffic and expensive homes. Now they are trying to fix the damage.

The challenge, and all its many complications, is playing out in real time in this city on the edge of Silicon Valley.

Google wants to build a campus of more than 6 million square feet here, with...