You've partially answered your own question. The most critical and best protected parts of a flight data recorder and a cockpit voice recorder on a modern airliner are extremely small and are in effect armored with multiple layers of materials intended to provide both crashworthiness and heat resistance -- they can sit in the middle of a post-crash fire for quite some time and still protect their contents if their cases are not significantly damaged. So, as you observed, the tradeoffs for using those materials are cost and weight, at least in the first instance.
The way the recorders are installed also supports their likelihood of surviving a crash. Each manufacturer identifies structures that are likely to break away during a crash or to remain more or less free of fire for a prolonged period. So, it isn't just how they are made, but how they are placed as well.
Finally, aircraft are designed to be as light as possible wherever possible (for efficiency), saving their structural strength for where it is needed. However, they also are designed for "crashworthiness." If an airplane does not come down on its landing gear on a suitable surface, you want the occupied parts of the aircraft to be strong (to protect the crew and passengers) and the other parts to break away rather than endangering the occupants by passing through the cabin or, even worse, staying intact at the cost of transferring the forces of the crash to the occupants.
If the surrounding structures "crumple," much of the energy that goes into crumpling them is dissipated. A too-strong airframe might look much better in the aftermath of a crash, but it could wind up subjecting its crew and passengers to non-survivable forces. You can see some examples of this phenomenon in pictures of aircraft accidents from the 1950s in particular, especially where the aircraft ran off the end of a runway -- the airplane looks pretty good overall, but everyone inside died.