They are called "Reporting Numbers" and are used to identify individual trains. The numbers are still used "behind the scenes" by the railway industry but no longer officially appear on the front of trains.
This website gives details of the reporting number system used in the North Wales area:-
http://www.2d53.co.uk/Headcode/headcodeA.htm