In a sense, it is all about watts. Crank out 300W on the level, against wind, with wind, whatever.... or crank out 300W going up hills... and the results will be the same.
I have a lot of troubles keeping up high power on flat land. So, the hills become a big motivator. Yes, downhills can be a bit of a recovery period. But I went on a hilly ride recently, and there wasn't enough time to recover between hills. So, as the day wore on, I just got wore out. I had my gearing so I could do a mile or so at 10%. But hitting 10% after 10%, and a few stretches peaking over 20 or 25% just put me over the top.
According to Strava, my calories burnt was greater during the flatish rides that week, just because I went further/longer. And Strava didn't calculate the flat rides included a large backpack.
Anyway, so burning energy is watts x time.
Hill climbs may give a greater workout only if one pushes out more watts going up them.