Cooling fan running with engine off?

It’s a function of the fan being controlled by a thermostat. There probably would be nothing wrong with letting the engine cool “by itself” (which is what happens if the design removes power from the fan when the ignition is off), but since the normal operation of most cars is to run the fan when the water temperature exceeds a set threshold, it does so even with the engine off. The rise in the temperature of the water after the engine is shut off is because of the residual heat in the engine and the lack of further airflow across the radiator - hence the running of the fan.