Why is my car overheating at idle or in heavy traffic?

Maybe yes, maybe no.
In any event, the thermostat has nothing to do with the cooling fan failing to run, so you can dismiss that theory.