A court martial is required if a ship is lost. Even if it a "no fault". For example, and surviving captains at Worf 359 would have to face a court martial, to both make sure they fought like they should of, but also to find information on how to better face the Borg threat.
And if you think Captains who lost ships do not get promoted or gain other ships, tell that to Elliott Buckmaster, Fredrick Sherman, Forrest Sherman, Charles P. Mason, and John M. Hoskins - What they had in common was that they where the captains of US aircraft carriers lost in battle. All became admirals, and John M. Hoskins was giving command of the USS Princeton
(CV-37), after the loss of the USS Princeton (CVL-23).
and Charles Purcell Cecil lost a ship and had two navy crosses and a couple ships named after him.