There's this thing called a Chain of Command.
In a military context, the chain of command is the line of authority and responsibility along which orders are passed within a military unit and between different units. In more simple terms, the chain of command is the succession of leaders through which command is exercised and executed. Orders are transmitted down the chain of command, from a responsible superior, such as a commissioned officer, to lower-ranked subordinate(s) who either execute the order personally or transmit it down the chain as appropriate, until it is received by those expected to execute it. "Command is exercised by virtue of office and the special assignment of members of the Armed Forces holding military rank who are eligible to exercise command." [1]
In general, military personnel give orders only to those directly below them in the chain of command and receive orders only from those directly above them. A service member who has difficulty executing a duty or order and appeals for relief directly to an officer above his immediate commander in the chain of command is likely to be disciplined for not respecting the chain of command. Similarly, an officer is usually expected to give orders only to his or her direct subordinate(s), even if only to pass an order down to another service member lower in the chain of command than said subordinate.
https://en.wikipedia.org/wiki/Command_hierarchy
Under normal operating circumstances, within a known military structure, such as a Company, an order given by an officer to anyone enlisted is taken as given by their direct superior through the well established Chain of Command. This only happens when everyone knows who is in the Chain of Command and there's absolutely no possibility of there being a contradiction of those orders.
This doesn't mean that when an officer orders a private to do push-ups for a minor infraction that the order is ignored. There's also the Uniform Code of Military Justice (articles 90-92, discussed here) that require all orders from a superior officer to be followed, unless they are illegal orders. There are also requirements for the soldier/sailor/marine/etc. to explicitly not follow illegal orders. Even if an enlisted is given by an order by an officer, they have the right to talk to their immediate superior to validate the order.
If what you are really asking about is the possibility of using nukes, I wrote an Answer to that here. But really, the same situation happens regardless of if it's nukes, conventional bombs, artillery, foot soldier deployment, or whatever. The person getting the order has to decide if it's a legal order, and if it's outside of the normal Chain of Command, they can take it to their regular Chain of Command for verification. If they get contradicting orders, they have to make another decision which usually means they follow the order from their known Chain of Command, even if it takes hours (or more) for their supervisor to contact their supervisor on up to whomever needs to make that level of decision.
Personal Anecdote
When I was in Army Basic training, we were explicitly told by our Drill Instructors, who were a variety of sergeant rank, that no one was allowed to enter the barracks unless they had the keys to open the door themselves. We were told this applies to even a general, since we wouldn't be able to know the difference between a real general/officer or someone simply posing as one. As it turned out, during my fire watch that very night (well after people were asleep), a general came to the door and ordered us to open the door for an inspection. We refused, since it wasn't a legal order. We still saluted and did the pushups the general ordered, but we kept telling him to go to the officer/NCO on night shift to open the door. They eventually did so, as it turned out to be none other than the General in charge of the whole base. Even though the general was POed, we weren't disciplined due to following the orders of the known Chain of Command.