Sometimes, occasion dictates that you must walk away from a cat--you might be going to the corner store, or the train station, or it might be a cat that you greeted on the sidewalk. Though it's sorely tempting, you must not look back as you walk away from the cat. Ever. Even if it's just to sneak a glance and see where the cat is in relation to yourself. The cat will take any glance--friendly, hostile, indifferent--as an invitation to follow. You might, in a fit of well-meaning, or later in a fit of exasperation, attempt to lecture the cat, and encourage it to stay where it is. You might even lead the cat back to that spot. All will be in vain. The cat will continue to follow, because you've paid attention to it. The type of attention doesn't matter--any attention at all will cause the cat to follow.
The only thing that will stop a cat from following you is ignoring it. For a while, it might trail behind you--it might feel as though you will never shake the cat--but provided you keep your gaze firmly ahead of you, it will eventually lose interest. This may take a long time, but it's possible to do--provided you can keep your eyes off the cat.