Modules shouldn't be counted because the foundry has the same number of slots for those anyway. But melting ore adds a +50% productivity bonus itself, which messes with those ratios as well. Overall, the foundry IS the best choice for every recipe in its list because the ingredients and product rates are balanced accounting for all these things. Easiest way to test is to put 100 ore through a given chain of production buildings and seeing what it ends up producing. Turns out, the foundry wins. Even with copper cable, surprisingly.
The comparison is not with Ore -> Iron Plates (Furnace) -> Gear/Pipe/Steel -> Engine, it's with Ore -> Molten Iron -> Iron Plate (Foundry) -> Gear/Pipe/Steel (though some of these are more efficient to cast directly depending on quality tier of productivity modules) -> Engine. You still get the base foundry bonus, but additional processing steps give more chances for productivity to kick in.
Even your copper cable example suffers from this at higher productivity.
Foundry: 5 Molten Copper -> 3 Copper Cable (5 with max modules) = 1.33(1) Molten Copper per Cable
Foundry: 20 Molten Copper -> 3 Copper Plates (5 with max modules ) = 6.66(4) Molten Copper per Plate
EM Plant: 1 Copper Plate -> 3 Copper Cable (5.5 with max modules) = 2.22(0.73) Molten Copper per Plate
At Legendary T3 Productivity, you use over 25% less copper per cable by casting and processing it in the EM plant