Not at 5. 10, maybe.
Those are not the thoughts of a 5 year old.
It's not that they are planning the sequence and understanding all the cogs in the machine. It's that they've seen the same situation play out 10 times already with other kids. All they need to do is copy it exactly.
Unless someone taught that concept to the 5 year old.