Cast iron is valued for its ease of machining without distortion, and the way it copes with (intended) sliding. It is not particularly strong, and its resistance to shock loading is only moderate, but many sliding and rotating parts rely on it, particularly where sliding is relatively slow and lubrication is intermittent or neglected.
Mild steel, on the other hand, is (as you have found) cheaper and more readily available. As well as being almost as easy to machine, it can be bent and forged (which cast iron can't). Other benefits are in its ease of joining by soldering, brazing and welding, the fact that it can be case hardened, and it is tougher than CI.
For pistons in full size internal combustion engines, neither is used as better characteristics are available in light alloys, particularly for heat conductivity. Model engines can still use cast iron as the parts are much smaller, (the clue is in the term 'model' and they produce only low power, and do not run for long at a time. For petrol or diesel road vehicles, cast iron pistons were obsolete by about 1924, for aircraft they did not last through WW1.
Hope this helps with some background
Regards, Tim