If a training programme raises employment through an increase in confidence, confidence is a mediator: it sits on the path between the programme and the outcome.
If the programme works better for women than for men, sex is a moderator: it changes the size of the effect without being on the path.
The two are often confused because both involve a third variable. The test is whether the variable comes after the intervention (mediator) or exists before it (moderator).