To attract Tesla, Bejing rewrote its rules for foreign auto businesses and offered tax incentives and cheap land. In return, the company would jump-start China’s homegrown electric-vehicle industry.