So do battleship guns. They just take a hell of a lot longer to do it.
Power is the
rate at which energy is discharged or work performed. So how can they be the same if one takes hell of a lot longer?
Glad you asked!
Power is described in terms of joules per second, i.e. watts. A 60 watt light bulb therefore uses 60 joules every second. This works well for a continuous discharge situation, but not for something that has to operate in bursts or pulses, or in short spurts of activity. It therefore isn't particularly useful to measure weapon output in watts, except occasionally with lasers, when trying to assess the power class of a particular weapon.
I'll add a new example for you: from "Mind's Eye" we know a starfleet phaser rifle is in the megawatt power class (about 1.05 megajoules per second, in fact). As this is comparable to much larger laser weapons currently used by the U.S. military, we have an easy point of comparison: based on their effects, it's clear that phaser rifles are far more efficient (around 80% compared to 30%) in putting that energy into a target, which means a phaser rifle discharge can put something like 800kJ into a particular target in a one-second period. Compare this to a .50-caliber browning machinegun firing at 600spm; at this rate of fire, the BMG fires ten bullets every second, each bullet having about 20kJ kinetic energy. This means the BMJ will put around 200kJ into a target for a one second burst.
This means a Starfleet phaser rifle is about four times as powreful--in terms of yield delivered to target--than a modern heavy machinegun. Probably, it would be more comparable to, say, a grenade launcher or an Oerlikon gun. This seems perfectly consistent with the way phaser rifles were used in the Trekiverse.
As for starship phasers: the matter is trickier because battleship guns have a much lower rate of fire (even compared to contemporary weapons, which are speed demons by comparison). If you scale this up to starship combat, you find a reference in "Who Watches the Watchers" that a 4.2 GW power generator is "enough to power a small phaser bank," which could mean a discharge of 420MW for up to ten seconds before having to recharge, or 200 MW for twenty seconds, etc. While a single short discharge would indeed be comparable to an Iowa-class cannon shell, the phaser banks would be able to outgun even the Iowa by being able to fire these discharges more often, with a longer range, and with better accuracy.