Probably as the old ones wore out. Since kerosene is still sold, there's no need to get rid of them. In a yard, electric would be fine, because batteries could be stockpiled in the yard office. On rural branch lines, it might be easier to use kerosene, and keep a jug in the caboose. It could be refilled in small towns that might not have sold railroad-style lantern batteries.
One of our local grocery stores, in a northeast Kentucky town of about 5000, with a small university, still sells kerosene lanterns, advertised as "essential for any household in case of a power failure".