To me, riding a loop with hills is easier than riding the same distance on flat ground
Well, if you mean you enjoy the hilly ride more, that may be true. And it does take more mental discipline to go hard consistently on a flat than when fighting a hill. But to average a given speed, the up and down ride will always take more work. Fighting gravity will always cost you more than it will give back to you on the descents.
but riding down, gives you time to recover.
But it doesn't have to. For the most part, that's a choice you make. Except on long steep descents where you reach spin-out speed and then coast, you could keep pedaling hard and putting out power on the descents. That may take even more discipline than time-trialing on the flat, but watch pro riders on a hilly time trial and see how much time they are "recovering."
Bottom line: elevation gain, defined as total accumulated climbing without subtracting descending, is a good general measure of how hard a route is. Go do a century with 2000 feet of climbing, and then do one with 10,000, and tell me how tired you are after each, regardless of your pace.