if you measure the output of a battery, it is like a dc voltage with 0hz hence the average voltage is the max voltage (in this case 9V)
but if you measure the output of a frequency generator (like a zapper is) the duty cycle is usually 50% (which means that half of the time the voltage is around 0V and half of the time the voltage is max voltage (9V)) so the average voltage is 9V*0.5 = 4.5V