I've had a couple horses do this with me. If they walk off, i keep my foot in the stirrup and ask them to stop, when they do so, i let them sit a couple secs, then dismount/pet. Then you repeat the process. I've found that if you get off when they are not still, they think "ohhhh if i walk off when they are trying to get on i don't get ridden right now". I also back my horses right when I get on (when they are standing still) then ask them to go forward, or sit still for a couple mins. They never associate getting on to moving forward then. I might of explained that wrong, but hopefully you can grasp it, lol.