Examples with my Welsh terrier Rhubarbe.
Living in Paris, he and I used to walk in the Champs de Mars by the Eiffel Tower at least twice a week and sometimes more. He knew the way there and back by heart. He walked without a lead and once in the park, which is not closed, would walk in front of me or stay behind. As a result I would lose him. More often than not by whistling or returning on my steps I would find him, but sometimes not.
I think that when he couldnt find me, there was perhaps anxiety and a moment of panic but never did he return to the flat which was all of 10 minutes away! So what did he do? He obviously had memories of where, at the edge of the park we had been and the safest move for him seemed to be to return to one of these places. My task was to try and remember where we had been and second guess him to find where he might be now! In his head, on returning to a former place (supermarket, butcher, fishmonger or, sometimes but rarely, a bench in the park) was he sure that I would come back or at least surer than if he had gone back home? It was up to me to return to all these places until I found him sitting squarely in front one of them!
Once I lost him completely, returned home and had no news of him until the following morning. This time again he didnt take the easy route home, but crossed two major roads to sit in front of a café I had been to with him two weeks previously. It was snowing and he sat outside all evening, shivering with cold, until the kind waiter took pity on him and took him to his house and to a vet the next day. From the number tattooed on his leg the vet knew who is owner was.
On the other hand, when Rhubarbe went to the Champs de Mars with a dog sitter he didn’t particularly like and had had enough, then he would return home without hesitation. This suggests that the emotional attachment between master/mistress and dog (in this case) plays a role in the decisions taken when one loses the other. Is it specific to dogs? Does it happen with other animals, and domestication must play a part.
If I got lost in a wood walking with him, I would follow him to where he went and we would always get back to a place I recognized. We were never very lost but Im sure his sense of orientation to find the car was better than mine!