Hi Meredith, it’s not contradictory for a utilitarian to say that punishment is intrinsically bad while admitting the consequences are good. This is discussed a lot in value theory.
The strategy to employ here is distinguishing intrinsic value and instrumental value. Punishment and retribution is thought to be intrinsically bad. Why? Because we’re inflicting harm on someone. But they’re considered instrumentally good, as that harm is being inflicted on the wrongdoer. Bentham will also like argue that punishment is instrumentally good as a form of deterrence.
Holism about value then argues that if we calculate both the intrinsic and instrumental value of punishment, we’ll likely get a net good. Some thinkers have also argued that this explains why we have conflicting attitudes when it comes to punishment: we want retribution but it pains us to witness suffering (even on the deserved).