The state’s electric grid was experiencing rapid and unprecedented changes even before Pacific Gas & Electric and Southern California Edison began shutting off power to millions of people in a desperate scramble to prevent their transmission lines from sparking wildfires.