The wither cage is just big enough to hold the wither, so it ends up in the spikes and takes damage. The water source is outside the main cage and around a corner, so it's protected from the wither itself; there's only flowing water at the bottom of the cage.