Both rigid MTB's and gravel bikes have shifted a fair bit in the last few years so they can look quite similar I guess but they come from different directions.
Gravel is defo heading more towards an off road geometry rather than the road bike with more clearance and bigger tyres that it started as. Seat tubes are getting shorter, as are stems where as top tubes and bars are getting longer. Forks tend to be shorter and head tubes longer than adventure bikes still though and there's still plenty of GB's about that are more road focussed.
The flat bar bikes seem to be coming from a more old school MTB direction IMO, a natural progression after modern MTB geometry went in a very different direction. This style geometry seemed to flirt with the hybrid market for a while and kept narrower bars + tyres but more and more seem to be beefing up and going down the adventure route. This being the case and seeing how gravel has changed they have started to tread on each other's toes I guess? They are different though.
I spent a lot of time thinking about what style bike fits where in the last year or so as I was trying to get a collection that covered all my bases. I thought of it as a chart with race road bikes at one end, downhill MTB at the other and everything else in-between. Each style would be best for a certain terrain but others would also be capable, even if they were not the best tool for the job. The trick was to work out where I wanted to ride and therefore the best collection to cover the most bases. The chart was something like:
Race road- Road----- Hybrid- Gravel- Adventure MTB------ Short travel MTB- ---Downcountry------ All mountain- Enduro- Downhill.
Tarmac--------------------- Gravel track-- Canal/fields-------- Traditional trails---------Trail centre/technical natural-------Bonkers.
..... or something like that. So a GB could ride traditional trails but a short travel MTB would be better, an all mountain bike could ride steady fields but it would be overkill and the adventure MTB better suited, etc, etc. You could ride a road bike on a downhill course or DH bike up a tarmac hill but both would be hideous.
I have a 29er full suss that covers as far as I want to go towards bonkers and also a GB that I enjoy exploring canals, bridleways and back roads. When I got the GB I sold my road bike as I didn't like busy roads or being limited to tarmac. I then got a rigid On One Whippet as I'd always wanted to try a modern XC bike but found it covered the same bases as the GB so sold it and am now building a 650b hard tail to sit around the traditional trail/trail centre space.
IMO there's room for all the various styles of bike as riding them is ace! You just need to work out where you actually ride, where you want to and what bike(s) will allow you to get the most enjoyment from it.