What happens when a transformer turn on and off suddenly?
Answers
When a switch opens, a current drops to zero, but not a voltage. The voltage across the switch is known to be zero only when the switch is closed.
The automobile spark coil has switch, battery, and primary (solenoid) winding which are in series. When the switch is closed, the battery is in series with the solenoid (and maybe a ballast resistor, but that's a minor detail). That puts a voltage across the solenoid, which causes a rising electric current. At this time, the secondary (solenoid #2) carries no current, but that is about to change. The primary current magnetizes the iron core of the 'transformer' which is the spark coil. Magnetization of the iron stores up energy, just as charge in a battery does.
When the switch is opened, the CURRENT in the primary winding goes to zero, and the magnetized iron in the coil starts to demagnetize. Magnetization rising caused about +12V across the primary, and magnetization dropping causes about -12... then -120... then -300V on the primary. Meanwhile, the secondary is just as much an induction winding on the core as the primary was, and it gets its own (rather higher) voltage, up to -40,000 V, because it has more turns around the core (of finer wire) than the primary did.
Then another switch closes. The 'other switch' is the least-insulated metal-to-ground part of the secondary circuit, and it only closes in the sense that it ceases to block current. There's now a small lightning-bolt, and a conductive blob of ionized gas, in a small gap between the spark plug electrodes.
Now, the voltage on the secondary drops as the current flows in the direction that demagnetizes that iron core, and when there's no longer enough voltage to keep the gap filled with ionized (conducting) gas, the spark winks out.