There was something called the “Tender Years Doctrine” in law that mandated that a child in their “tender years” should be given to the mother. It was basically a patriarchal concept that “women are natural caregivers” and “men are tough dudes who should work for the family” type of shit.
https://en.wikipedia.org/wiki/Tender_years_doctrine:
The tender years doctrine is a legal principle in family law since the late 19th century. In common law, it presumes that during a child’s “tender” years (generally regarded as the age of four and under), the mother should have custody of the child. The doctrine often arises in divorce proceedings.
The doctrine has been increasingly going out of favor but it still exists in many states (in the US I mean). Even if it’s not official, many family court judges still kinda believe it and it affects their decisions:
Critics of the family court system, and in particular fathers’ rights groups, contend that although the tender years doctrine has formally been replaced by the best interests of the child rule, the older doctrine is still, in practice, how child custody is primarily determined in family courts nationwide. Despite this, in 1989, the Massachusetts Supreme Court’s Gender Bias Study reported that “Fathers who actively seek custody obtain either primary or joint physical custody over 70% of the time.”[citation needed] However, others argue the 70% figure is highly misleading because its definition of joint custody was so broad as to include visitation rights, among other issues.[6]
Critics maintain that the father must prove the mother to be an unfit parent before he is awarded primary custody, while the mother need not prove the father unfit to win custody herself, contrary to the Equal Protection Clause.[7]
Yeah I know it’s wikipedia but it tracks this particular issue pretty well. Feel free to find other sources to confirm yourself.