I think it depends not only on the type of bike but on the actual riding type you are going to use the bike for.
I happen to have a number of different MTB bikes, and after adjustments are made, I found that BB-axle to saddle height is the same, and saddle to handlebar is the same.
I also have a hybrid that is based on a hardtail MTB with rigid fork and 700cx38 tires, so, very similar to a flat bar gravel bike. This bike is used more for commuting and relaxed riding, and I found more comfortable to have the handlebar closer to saddle (about 5 cm) and relatively higher.
This measurement is called "reach". Shorter reach means the torso is more upright and less weight is applied to the hands and more on the saddle. The few times I took this bike for more energetic rides (harder climbs) I found myself wishing for that extra reach. I have made some long road trips also, and for those rides, I use a handlebar arrangement equivalent to an even longer reach that allowed me to lean my torso further towards the front, thus having a lower profile (aerodynamics).
To make a generalization: Longer reach is useful for more energetic riding styles and where you want to generate higher torque and/or lower profile. Shorter reach is better suited for relaxed riding and commuting.
Regarding bike length, the relevant measurement is wheelbase: the distance from one axle to another. For MTB, longer wheel base feels more stable, specially on descents. Shorter W.B. feels more agile and easy to turn. Too much W.B. feels hard to turn and generally difficult to maneuver. For Commuting, longer W.B. feels somewhat more comfortable, but makes it mode difficult to maneuver through tight spots like parking, staircases, etc.
However, take into account that for two different bikes with the same wheel base, the relative position of BB axle can be different. This puts pedals at a different position relative to both wheels and that has a whole range of effects on riding. The measurement is "chainstay length". I have not experimented with sufficient chanistay lengths to give feedback on this.
Regarding bike height: For MTB it is advisable to have more standover clearance than for other disciplines. More clearance also allows for more travel or adjustment range for telescopic seat posts. But, generally, the rather small variation in top tube height from one size to another is rarely an issue in actual riding.
For riding on smooth terrain you usually do not need a lot of clearance. As long as you can stand on the ground with the bike upright between your legs and having about 10cm (4 inch) of clearance over the top tube, you should be fine. For riding over roots, rockgardens and other irregular terrain features, I advise more clearance (lower top tube) in case you fall out of the pedals.
Some people use telescopic seatposts (or manually lower the saddle with a quick release seat post clamp) to ride over difficult terrain, specially on descents. Ideally, your bike should allow to set the saddle a bit lower than the lowest you need and a bit higher than optimal pedaling height, so your actual setting is always somewhere in the middle of the range and never on an extreme.
On a side note: some bike models change only one measurement between certain sizes, usually top tube height, while keeping the others basically equal.
In conclusion, search for exactly what measurement(s) actually changes for the particular bike model(s) you are considering and take into account the type and style of riding you are going to use the bike for.
Also, consider that the human body is very flexible an can adapt very well to small changes. I've met fellow riders that use their bikes such that, proportionally, I would find them extremely uncomfortable for any use, but they would't change a single thing on their bike, fit-wise.
Chances are, any of the two sizes would suit you well and only after some time of use you'll find the adjustments you need to make. In that time, even the "perfect fit" for you may change according to age, habit, riding progress, etc. So I advise not to stress too much and use the bike.