A number of jobs, particularly those salaried as opposed to hourly paid, are by regulation required to be "advertised".
I am fairly sure this is an urban myth - I've seen it quoted a few times, and nobody has managed to find the regulation when anyone has asked.
It is arguably good practice to advertise externally rather than internal / word of mouth, and some organisations (including many in the public sector) have a policy that they will advertise all jobs externally. Although when there are redundancies happening, they will often do a first round for existing staff whose current jobs are 'at risk', and only if that does not produce suitable candidate/s they will advertise externally.
A further reason is where those already in place in comparable positions are on a lower salary; don't want to advertise what might be payable.
or alternatively, they want to see how little they can get away with paying a new person (depends on the particular 'market' for that job at that time.)
personally, i'm old fashioned enough to think it's better all round to have a 'going rate' (or a range of rates and a fairly transparent scheme for establishing how people get to be on the different points on that range) for the job...
with some transport jobs, it can be hard to tell (my background is more buses than trains) - a basic rate can hide allowances (e.g. payments for unsocial hours - where such payments still exist) and an 'average earnings' or 'up to' figure can hide that there's a culture of doing a lot of overtime / rest day work.