A “terrible error” by the BBC led to the collapse of a high-profile trial of a woman accused of an illegal abortion.