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.
Spoked wheels aren't cast because it's hard to machine them. You can easily CNC them if you really want. But that would be insanely expensive and wasteful and not any better.
I've watched enough Chip Foose on TV to know that in the custom car world it is commonplace to start with a solid blank wheel and CNC away 90% of the face to achieve any particular design. It takes only minutes, and unlike casting or forging you do not need to purchase hard tooling for each different design.
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.