Dogs learn by association. What does that mean?
You may hear from dog trainers that dogs learn by association. This means that dogs learn by associating a feeling with a situation, experience, and/or person. 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 why positive reinforcement is such a powerful and reliable training method, and way of interacting with your dog in general so that they feel good about doing things with you, and thus will want to do more. A situation where learning by association is demonstrated clearly and easy to understand is when your dog goes to the vet and has an unpleasant experience. The way the experience felt 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!