For the simple reason that the traffic levels to build a freeway in one location do not correlate to traffic levels in an entirely different location...
The fact is that many rail operators around the world are committed to constructing no new level crossings. Whatever reason for that makes level crossing grade separations more important than other road projects in the same area.
The equivalent in Melbourne is to ask why Ramsden Street level crossing in Clifton Hill has not been replaced, given there is enough demand to justify building the Eastern Freeway.
That area is quite hilly. That railway goes over many roads between East Richmond station and just and block from Ramsden street. It goes over Rose street, than slightly uphill to Ramsden street. See below for why this is not quite the equivalent.
The perils of geography are a clue to the survival of so many level crossings. The Armadale line in Perth travels through the flattest geography of all the suburban lines - hence it is not surprising that it has so many level crossings. The equivalent to this in Melbourne is west of Newport, or down the Frankston line after Mordialloc, where the terrain is flat and there is little natural assistance for over or under road bridges.
The Armadale line is also the busiest and seems to have level crossings with some busy roads. Also, the flat terrain explains, partly, why level crossings were constructed in the first place.
In Newport there is a flyover that replaced an interlocked gated level crossing in 1960.
Electrification in Perth - as in many places - had little influence on removing level crossings. Very few civil works undertaken in conjunction with electrification had any impact on the cost or practicality of removing level crossings. Frequency of trains did increase, but those issues could be dealt with on a case by case basis with no direct correlation to the electrification program.
I don't get this, especially the last sentence.
Say a road and a railway are built in different directions such as to cross each other:
*The cross on the same level to save initial
cost. The crossing is fitted with full-length gates and wicket gates and someone is hired to operate them.
*Decades later, with the full-length gates relpaced by half-length barrier and the wicket gates by automatic pedestrian gates, road and rail traffic are much greater and there are complaints about traffic congestion at the level crossing.
If the road or rail builder (or maybe both) had stretched their budget and built an overpass or underpass, then a level crossing that busy would have been avoided.