Codes require ventilation in bathrooms. It can be either by fan or by window.

Just as there is no law requiring your car to have a speedometer, there is no requirement that there be any switch, anywhere, to turn the thing off.

There is certainly no requirement that the fan be on a switch separate from the light.

Code-required ventilation is a minimal requirement, and there are many situations where it is desired to have more. There are also physical reasons why it's desirable to have the (small) fan run longer, than have a (big) fan run for short periods. So, a healthy market has sprung up selling special timer switches for bath fans.