If you make your hydrogen by reforming steam and natural gas, you do emit CO2.
You don't have to make your hydrogen that way, and even if you chose to, you could trap the CO2 rather than venting it atmosphere, but that does cost money.
What makes you think that? It always seems to make sense to size you primary power source to produce little more than the average power output required, and add a battery to cover peak demand. That's the idea behind hybrid cars too.