Like aeroplanes, do rockets also contains some black-box kind of thing to see what went wrong at the time of failure?
Key data for the Columbia accident investigation was provided by recovery of the MADS (Modular Auxiliary Data System) recorder which amazingly survived reentry and was found largely intact.
The MADS recorder captured crucial engineering data that wasn't sent to the ground through telemetry.
As the first spaceworthy orbiter, Columbia was instrumented with hundreds of sensors—strain gauges, temperature probes, and the like—to study the loads and stresses on the vehicle during ascent and reentry. These sensors fed into the OEX box, which recorded the data on magnetic tape. Columbia was the only orbiter with an OEX recorder. And quite coincidentally, the box was going to be removed after STS-107 in order to save weight as part of Columbia‘s refit to fly a supply mission to the International Space Station.
Note OEX (Orbiter EXperiments) recorder is another name for the MADS recorder.
This wasn't a traditional "black box" though; it wasn't intended to be survivable, and Columbia was the only orbiter that had the system. It was a left-over from testing when Columbia was the first shuttle and was being checked out in flight.
The press at the time often referred to it as "Columbia's black box" but that was not really accurate.
While there is onboard recording, the significant difference between launches of space craft and those of aircraft is the extensive realtime telemetry used in rocket launches.
Every piece of data that can be sent live to the ground station is sent. This is essential in an endeavour which is still incredibly dangerous and with high odds of destruction or at least non-retrieval of wreckage (because it blows up, remains in space, or burns up on re-entry, out is lost in the depths of the Pacific)
So yes - there is often the equivalent of black box, but that is not relied upon and is not the main storage of data.
Another example: The Orion Ascent Abort-2 flight is going to be equipped with a series of Ejectable Data Recorders (EDR) to return telemetry on the flight in case the main telemetry downlink (a radio link) partially or completely fails.