Would the electrical circuitry of an immersion heater be affected if taken out of the water immediately after switching off?
a bit like a resistor

It is a resistor.

Although power dissipation stops immediately after you cut the power, there will still be heat stored in the resistor itself inside the metal enclosure. That is called "heat capacity".

If you don't let the heater cool down in the water this residual stored heat warms up the heater instead of the water making it reach temperatures above the boiling point of the water and that could damage the heater. The metal might oxidize and thus change color.

Besides, leaving it for two minutes after switching off will allow the water to cool also, which defeats the whole purpose of heating the water

But that residual heat will also heat up the water a bit, if you take the heater out immediately that heat is lost (to the air).