Have you ever known a dog that runs away at the first chance it gets? Doesn't come back when called? Bolts out the front door and is off down the street before you even get your shoes on?? Have you ever wondered why?
Did you know that not all dogs do that? It has nothing to do with the dog being a bad dog. So, why does the dog do that? Because something down the road or way off in the distance has rewarded the dog more than the owner.
Boiled down basic idea - if your dog wants to be with you, then it won't run away. That means that you keep the dog entertained, prevent boredom from sinking in, and generally provide it with what it requires mentally, emotionally and physically.
I have heard people say that "all beagles are runners" or that "small dogs run and don't recall". I don't believe this is true. I have had beagles that don't run. I have known small dogs that don't run and do recall. (By "run", I mean run away)
If you make yourself important in your dogs life, then it won't run away. I have taken foster dogs that are 'runners' and they don't run. Why? Because I make myself important and teach them boundaries. We don't have fences on my property. The dogs could all run if they chose. They don't.
Train your dog not to run away and it won't.
Teach your dog that it gets a reward when it recalls and it will come back when you call.
Show your dog that you are important and that they should cherish every moment with you and they will never want to leave your side.