While it might seem unjust... Those are done for the child. The third person involved in such event.
People, we, tend to always focus on the two people that had sex.. The one that should suffer the least from such circumstances is the third person, the child. Hence why the courts usually rule in favor of them.