Well this is because something else in the cooling system is very marginal, and using the AC just pushes a marginal system over the top into the red zone. So you might have a clogged radiator, a sticking thermostat, or perhaps your fan clutch is defective. You could also have a collapsing radiator hose or a defective radiator cap or a loose fan belt. Worst case scenario is a bad head gasket.
Overheating is actually a much more complex problem to solve than many people realize, and can have many causes.