Well, command of the starship is a very special position that encompasses total superiority over everybody else aboard, at least on "ship matters" - on those matters, LaForge could have given direct orders to a Grand Admiral or the President of the UFP when holding that position.
Being placed in command of a survey team does not give that sort of authority. Within his appointed team in"Pen Pals", Wesley can boss around people senior to him in rank, but that doesn't make him capable of giving orders to LaForge.
In both cases, however, rank is but a minor consideration in placing these people in their respective (temporary) positions of command. This would be true in the real world to some degree as well, in situations calling for flexibility. Only at higher ranks and in positions of some permanence would it become prudent to permanently promote the assigned team leaders to bolster their formal authority - at least to make them senior to their current underlings, but possibly also to make them equal in rank to the comparable leaders of comparable teams elsewhere. Yet the higher the ranks, the more complex the promoting - so people from Major to LtCol to Col to Brigadier may well end up doing the same job in parallel units, without "equalizing" promotions.