Goal: To keep you moving.
Well, slipping spinning wheels are not very useful to keep a car moving forward. Slipping wheels are also bad for lateral stability (slipping off the road).
There is automatic traction control and manual traction control.
Traction control per se has nothing to do with 4WD or AWD. It is just another stability enhancing feature. It is also found on 2WD cars.
I'll focus here on automatic traction control. Manual traction control will follow separately.
Heart of all traction control systems are wheel speed sensors. Since ABS was introduced all cars have wheel speed sensors on all wheels.
In case one or more tires are slipping the computer will tell a device to slow down those tires. The device(s) accessed by the computer could simply be the individual brakes or they could be friction adding devices close to the differentials.
All these control devices have the same purpose: Slowing down tires that rotate faster than would be appropriate for the vehicle's speed. If needed the engine will also be told to produce less torque.
If all 4 tires slip on a 4WD, traction control will not be activated but the computer will tell the engine to produce less torque.
Traction control devices could be found at the wheels (brakes) and/or at all three differentials (variety of friction adding devices).
Why do wheels spin?
Well, remember how the differential works? The differential reacts to resistance. If one of the two tires on an axle is on a slippery surface it has less resistance (traction) and the differential allows it to turn faster. If one entire axle slips, the center differential allows it to rotate faster than the other axle. Both scenarios are bad and traction control intends to slow down slipping tires.