https://www.youtube.com/shorts/UsKDkZqvh4U

This is the first of a series of videos out of Kentucky. Watch all 4 shorts to get the full picture. Here's the cliff notes: baby is born, mother doesn't want to have anything to do with it. She signs over full custody for the baby, and refuses visitation, then disappears for 4 months. Then, in a "motion hour" (I don't really understand the concept, but it's apparently a KY courts things), she makes a motion to take the baby back. The dad's attorney argues strongly for his client, but the judge VACATES the custody order and literally hand the baby to the mom in court. Worst yet, she won't address dad getting visitation without a formal hearing, which would have been MONTHS in the future.

Custody laws are broadly written and subject to interpretation. Judges can take significant liberties and sometimes just completely ignore them.