You may have heard other pet parents or dog trainers say it. That all dogs learn by association. This means that dogs learn by attributing specific feelings to specific situations, experiences, objects, other animals, and/or people. Think of it the same way that when you were very little and your parents would take you to see your family doctor and they would give you a lollipop, at the end of your visit to the clinic. Dogs learn by association in a very similar fashion, but on an even deeper level than we do. And this is because this is the primary way in which dogs learn how to best navigate their environment in the safest way possible. Learning by association is a powerful mechanism designed to help all animals learn and attribute meaning to something which then allows them to know how to react to it the next time.
This is a leading reason why positive reinforcement is such a powerful and the most reliable training method, and a way of interacting with your dog in general so that they feel good about doing things with you, which will then encourage them to want to do more.
A situation where a dog learning by association is demonstrated clearly is when he goes to the vet or groomer and has a rather unpleasant experience. The way the situation felt at that moment is what your dog is likely to remember, the next time he/she believes that the experience is happening or about to happen. This varies from dog to dog, but you can see with different behaviours and situations that dogs will respond in a way that lets you know that they are not willing to proceed because they expect an unpleasant circumstance.
This is a type of reaction and understanding of our environment that we employ as well, to help us make better decisions for ourselves. The main difference, however, is that you and I can reason others and ourselves into understanding why we need to go to the vet (or in our case the doctor's appointment) regardless of how the experience may feel. We understand that it's in our best interest and thus can push past any associations we've made, even if they were negative.
What can you do about it?
You can prevent your dog from disliking something like going to the vet, by going there frequently (even without an appointment or actual ncessity) and making it a positive experience, to simply show them and socialize your dog to the idea that being there doesn't always mean that something uncomfortable or painful will happen.
This works similarly to human doctors providing lollipops to children after their visit, to help build trust, a good feeling and a good association towards something that's basically inevitable.
This is why most vet offices will offer 'Happy visits', especially for young puppies and it's great because this ultimately helps vet visits be something dog's don't fear or dislike, but it also makes it easier for your dog's vet to do their work, and in a safer manner.
You can now take what you've learned and start applying it! You can practice creating a positive association to common disliked objects and experiences like vacuuming, or your dog's crate, or their harness and more. Just like with happy vet visits, the idea is to take things low, short and sweet but practice those regularly and in a fun way that will have your dog looking forward to the next time!