Pain Can Make Dogs Retreat
Dogs try to hide their pain from humans, in part because they fear increased pain if they are touched. So, a dog that is acting withdrawn may be in pain. Some dogs, especially senior dogs, may have pain that flares up, so they may appear withdrawn some days and fine the others. You should also keep an eye out for a dog that is more withdrawn after exercise, as that may mean that exercise is triggering some kind of injury.
Pain that is so bad that it merits a dog withdrawing from you is certainly something you should bring up to your vet. When their pain is resolved or under control, your dog should return to normal.
Mood Problems Can Make Dogs Act Weird
Dogs can develop psychological conditions, such as depression and anxiety, just as humans do. For example, dogs may feel depressed if a person or pet they care about died if they moved homes, or for a number of other reasons. In this case, it may be challenging to help your dog through their mood disorder without professional help.
Many of these problems can manifest in a few different ways, other than your dog acting distant. They can also make your dog stare at a wall, make your dog start acting strangely in general, or even work your dog up into a frenzy. They can also appear as more specific issues, such as only acting weird at night, or acting scared, or avoiding specific humans.
If your dog is acting distant suddenly, it is wise to reach out first to a vet and then to a professional trainer. There is only so much good that catch-all advice can do without knowing your specific dog and their history.