Our dogs can often find themselves in a similar position when we verbally tell them "no". Even if they have figured out that something they are doing is causing our reaction, it doesn't give them any instruction on what to do instead.
I try to remember this in the times that I either blurt out "no" in the moment (it happens, I'm human) or use a cue that I have taught such as "off" or "leave it" so that I can follow up with something to give the dog more information such as "let's go" if we're walking or "where's your toy" in the house.
I also find that it is helpful in many situations to teach your dog what you do want them to do, rather than just reacting to all of the undesirable options that they come with. One of my favourites is to teach a stationing or go to your mat behaviour in the kitchen during food preparation or meal time. I start by teaching my dogs a cue to go settle on a mat, and periodically reward them for remaining on the mat. Once the behaviour is learned, I will start to use it during our regular routine. I often start by cuing settle on a mat while I'm doing dishes, because it is easier for me to occasionally drop a treat on the mat while washing up. I will then move on to settle on a mat while I prepare food as well. After we have been working on this new routine for a bit, my dogs will automatically go settle on a mat when I enter the kitchen - no cue needed. They've learned that settling on a mat may pay off, so they are happy to optimistically station themselves there rather than under my feet.
Do you have a situation in which you are commonly having to tell your dog no?