Custody can be determined by the parents themselves in non-aggressive or non-acrimonious divorces or separations free of abuse or other aggravating factors, or by the courts themselves in cases where neither parent can mutually agree to terms beforehand.
If a custody case proceeds to court, the judge will consider things such as the child's welfare and best interests. The judge will look at the health and habits of both parents, their ability and history of being a primary caregiver, their living arrangements (new romantic partners, suitable quarters for a child, environmental concerns), and so on. The wishes of the child may also be given some weight, depending on the age of the child and the circumstances surrounding the case in question.
How to Change Custody and Visitation Terms
Custody and visitation terms are easy enough to change in amenable arrangements where both parents are on speaking terms and fine with moving the schedule around. Some paperwork may be involved via each parent's respective attorneys if there is a formalized schedule that needs to be updated.
In more contentious cases, custody and visitation terms may be changed by court order, generally requiring a hearing from both parties. The reasoning behind any potential custody or visitation change (a change in job hours, ability to take care of a child, living environment, allegations of abuse or similar) may be considered, and the opposing party will have the opportunity to defend themselves against any such claims as well as to reiterate their own stance.