Making a high performance, expensive, rare car is a small part of the recipe. Most Ferrari owners own more than one Ferrari (65% according to Ferrari of North America study from a decade ago or so, not sure if there's an updated number). A significant number of owners own more than 2. Ferrari famously has dealer prioritization and waitlists that reward you for buying more cars, just like Rolex which another poster mentioned below. When I was servicing these cars around 2015, many customers would buy FFs and Californias that they didn't necessarily want just to have the option to buy something like a first year 458 Spider, not even one of the particularly rare offerings. If someone got something truly low production like a LaFerrari or F12 TDF, chances are that customer had already bought 10+ cars from the dealer and immediately trades in many of their cars at a multi hundred thousand dollar loss to them as soon as they are able to get out of a "regular" model into a special edition. Ferrari drives/meets also serve as social clubs/networking which certainly does provide some positive value for many owners of these vehicles. Very few customers I ever met really cared about outright performance/$ and would have been cross shopping a Ford GT with a 430.
Also they are very specific owners. There's one guy here in LA, specifically the San Gabriel Valley neighborhood who realized there were a ton of visitors from mainland China flush with cash who were either coming as tourists or buying property, i.e. the "fuerdai" phenomenon. Cue a few strategically placed watch/jewelry and lambo/ferrari dealerships later, and I think he's one of the top sellers of their cars in North America...