So a pilot only needs to work 5 years to regain all the costs.
No, far longer (since the training costs are out ot taxed income, and NPV of money spent today in the future) but also the risk of doing the training needs to be rewarded, and as kalapattar said there is actually a shortage of pilots - only a few months ago Ryanair cancelled loads of pilots as they didn't have enough.
Length of time training is not the deciding factor in what you're paid, but it does heavily influence the number of people who are able to do a job. Particularly a job which for a European is essentially global.
If you need more cabin crew, you can get more in six months, an advertising campaign, some recruitment, a bit of training and they're there.
If you need more pilots, you can't, not only do you have to convince them to spend a few years on no pay, you have to convince them to pay, then you need to lease the planes, and get the simulators etc. built. It takes years and lots of investment to respond to pilot shortages. Pay is a supply and demand thing.
As others have said - why do women not want to pilots, and why do men not want to be stewards is the question, although also in Ryanair's case, I suspect a much larger proportion of their pilots are not from the UK compared to their stewards so it may have international differences too.