Not long ago, swaggering companies such as Uber and Airbnb swept through cities like a wrecking ball, establishing themselves before regulators could figure out how to rein them in. That’s changing as companies cooperate with local officials before diving in.