Castings can achieve shapes that are impractical to machine. A classic example is a spoked wheel. The spokes are really hard to make precisely with machining, but fairly straightforward when casting. Bandsaw wheels are virtually always cast, for example.
Also, the processes are not really independent. It can be much cheaper to do a rough casting, and then machine just the critical faces of it, instead of using an “off the shelf” hunk of metal and machining it all into shape. So it’s not really “casting is superior to machining” or vice versa. More that machining is high precision but expensive. Casting has some up-front cost but once the patterns are made, each item will use material quite efficiently.