Why does being flat take more energy?
Galaxies are flat. You have no problem with that. The universe is flat.
https://www.space.com/34928-the-universe-is-flat-now-what.html
But you have a problem with the energy required to make a teeny weeny planet flat? 'Immense energy' compared to a universe being created? I've told round earthers a million times on this site, not to exaggerate.
Galaxies are flat? Really? Oh, you must mean spiral galaxies, which are disk-shaped. They form that way because they are spinning. When they stop spinning, usually through galaxy merger events, they become spherical in shape.
The spinning provides extra energy needed to keep the galaxy in a disk shape -- look up angular momentum. So, yes, it takes more energy for a galaxy to be "flat."
The Universe has a flat spacetime geometry on large scales. This is a different idea than the word "flat" you would associate with a pancake. You are committing the equivocation fallacy: a flat spacetime does not mean pancake-shaped. It is a comment about the metrics one computes. Effectively, it means that parallel lines will always stay parallel. This would not happen in closed or hyperbolic spacetimes.
Since gravity operates empirically as a inverse square law, without angular dependencies, the most energetically favorable form is a sphere, which is why most large objects become this shape. It would indeed take more energy to keep a large object in a pancake shape than a spherical shape. Just blow up a balloon. Why doesn't it form a pancake? You can squash it into a pancake, but this takes extra energy.
Hopefully, I will not have to explain this to you a million times