Data and Geordi are of course equal in rank from season three onwards.
In real military hierarchies, the one reaching that rank earlier would have very clear-cut authority over the one reaching it later. That is, if the explicit need
arose for one to have authority over the other. But the LaForge/Data relationship (professional or personal) never ran into issues where Data's hierarchical superiority would have been of relevance.
Bev seems to be considered more suitable for the command than dozens of Lt. and even Lt. Cmdr. officers who are wandering around the Enterprise!
In that particular incident, the competition supposedly wasn't aboard the ship; the highest-ranking person was a mustard-shirted Lieutenant.
Of course, Crusher wasn't assigned to stay aboard the ship because she would have been particularly valuable there; she was ordered to stay there because Picard didn't want her down on the planet, where the away teams faced the hopeless task of locating a needle in a haystack and then protecting themselves from its sharp stings while deprived of the usual technological support of an orbiting starship. Picard was rather clever to assign Crusher a duty that would make it impossible for her to depart the ship (without facing court martial); merely leaving her as the CMO would have left open the possibility that she would send herself down on a medical errand.
It was incredibly forced and tactically unsound, but it sort of made character-continuity sense.