Every engine is different... But generally speaking the radial was less complex, and the inline (water cooled) had more components..
HOWEVER, the giant radial on the jugs had more metal in it, more weight, and a giant, large, complex turbosupercharger, whereas the P51 had a simple 2-stage supercharger.
Not just engines dictate costs, though... Sheer weight is on the Jug's side. That weight is made up of metals, composites, millions of things that had to be built and installed. That's all part of the cost.