A large internal fuel capacity (224 gallons for a P-51C compared to 85 gallons for the Spitfire IX) plus drop tanks was certainly helpful, but the Mustang's fundamental design was extremely aerodynamically clean, and had two particular features that maximised fuel efficiency. The first was the positioning of the radiator, mid-fuselage with an under-belly air inlet and carefully designed ducting that provided a small amount of thrust (a phenomenon known as the Meredith effect), resulting in a highly efficient cooling system. The Mustang also had laminar-flow wings, an aerofoil shape that minimised drag, though I gather they didn't achieve true laminar flow in practise (I'm no aerodynamicist, the full explanations seem to involve a lot of graphs and equations, see e.g. NASA's Quest for Performance: The Evolution of Modern Aircraft). When coupled with the Merlin engine the result was the exceedingly impressive range.
A key factor in the P-51 achieving its potential was the political and military will to produce a long-range escort. The Spitfire would have been hard pressed to match the Mustang's full range, but there were undoubtedly opportunities to give it longer legs (as per Paul Stoddart's Escort Spitfire - a missed opportunity for longer reach?)). John Terraine, in The Right of the Line, puts the blame firmly on the Chief of the Air Staff (Charles Portal) who was convinced that a long-range fighter would never have the performance to match a short-range interceptor and thus opposed any such developments. James Holland in Big Week also points the finger at Sholto Douglas and Trafford Leigh-Mallory, AOCs Fighter Command in 1942-43, for a lack of will and imagination. The USAAF, on the other hand, were actively searching for long-range fighters, the Fighter Airplane Range Extension Program (FAREP) initially focusing on the lack of shipping and thus ferrying possibilities to both Europe and the Pacific, but also then the tactical possibilities of extended ranges using drop tanks. It still took some time to fully appreciate the potential of the P-51 - P-47s and P-38s were used for escort duties while the first Merlin-engine Mustangs were intended for close air support with the Ninth Air Force - but by December 1943 the P-51Bs of the 354th Fighter Group had been assigned to the Eighth Air Force and were flying escort missions into Germany.