What it is
Counterconditioning means changing a dog's emotional response to something by pairing it with something they like. A dog who feels bad about a trigger learns, through many repetitions, to feel good, or at least okay.
It rests on classical conditioning, the learning described by Pavlov. This is among the best studied learning processes in psychology. The idea that pairing a stimulus with a good outcome shifts an animal's response to the stimulus is solid.
What varies is how well it works for a given dog, trigger, and history. Fear that has been present for years can be harder to shift than a new worry. Counterconditioning is a strong tool, not a magic one.
How it differs from bribing
A bribe is offered after the dog behaves. You ask for a sit, they sit, you give the treat. The food is payment for a behavior.
Counterconditioning works the other way around. The trigger appears first. Then the food appears. The dog does not have to do anything to earn it. The food is a message: "this thing predicts something good."
That is why it is best to do it with the trigger at a distance where your dog is not afraid. If your dog is too scared, they will not eat, and the pairing fails. Many people who say "my dog won't take treats near other dogs" are starting too close. See what over threshold means.