It is extremely common for dogs to avoid eliminating while being walked but then rush to eliminate upon returning home. This is interesting because there are two radically opposing reasons why dogs do this. One reason is that the owner has done an excellent job in housetraining and the other is that someone has inhumanely and improperly attempted to train the dog.
Dogs are creatures of habit. If from the beginning they only are given opportunity to eliminate in one area, then they will want to continue using that spot. Look at it this way, our culture and upbringing has taught us to use western-style private toilets to do "our business." If suddenly the law said we had to use phone booths in Jack London Square, we would "hold it" when we were out and as soon as we returned home we would rush to the privacy of our privy. So if a dog has only used his own private toilet area, he would naturally be reluctant to go elsewhere.
A second reason a dog will do this is because he was improperly housetrained. Some people erroneously think they should punish a dog when caught in the act of soiling in the house. If the dog is traumatized enough, he will avoid the mistake of eliminating in front of humans. If people are around, the dog will "hold it" for fear of being clobbered again. So again, he will wait until he can "do it" in privacy.
One of my students was concerned her dog was very uncomfortable because of holding it until she got home. I advised her to go on a full day outdoor outing with her dog and she would probably eventually get a pee or a poop from her dog. Sure enough, she did, and proceeded to lavish her dog with praise and a treat. From that day forward her dog went more readily when away from the house so both the owner and her dog were more relaxed when out and about.