Courts ensure fairness by providing the contemnor an opportunity to explain or defend their actions before imposing any punishment.