It's one of those civil/criminal law crossover areas so is possibly a tad murky.
Driving a car that isn't in roadworthy condition is a criminal offence; and the police can order an engineer to inspect a car after a crash to see if there were mechanical faults present that led to the collision. The driver can be prosecuted if the car isn't up to scratch; let's say it had bald tyres or dodgy brakes or something.
Given a successful the insurance company may use it as evidence to avoid paying out for damage to the defective car (assuming it was at fault); however this wouldn't remove any third party liability. Whether they would try and sue to recover costs is another matter. This is the civil side of the same coin.
On a smallish claim (less than six figures, at a guess) insurance company would just pay up.
On a larger claim, they may dispute fault due to no negligence (like when a stone in the road is picked up by a tyre and hits a car behind). If the mechanical failure occurred suddenly during the journey, there may be no criminal offence of driving an unroadworthy vehicle, as the car was roadworthy at all points while the driver was actually in a position to decide whether to drive it.
The insurance contract may exclude damage if the car's lack of roadworthiness contributed to the claim, but it would depend on the contract and the third party would be paid out if the driver was negligent, regardless.
The last repairer etc. could be liable, either through product liability (e.g., if new brakes fell off) or generally for negligent misstatement if the mechanic signed off a car that was clearly faulty. In either case, lack of evidence and lack of a worthwhile defendant would make claims against a repairer unlikely in practice, although there's no particular legal barrier to them.