A horse who walks off when mounting does so because it's been allowed to in the past. It's not a desired behavior, but I know lots of people who do not bother to correct it. Actually, my instructor actually trains her Saddleseat horses (ONLY the Saddleseat horses!) to walk off right away.
If you do not want your horse to walk off, the answer is pretty simple: don't let them walk off!
How you teach them that depends on the horse. Some horses, you can mount up, sit back an say "woah" and they will stand still. If your horse does this, you can repeat this procedure over and over again until she understands that she must stand still when you get on.
Another method is to flex your horse laterally. Position yourself to mount, and ask the horse to flex to the left by keeping your left rein tight. HOLD that position as you mount, and do not release. Now you've got the horse so it can't move forward, and instead it may move sideways and spin. You must keep holding that flexion, saying "woah" and asking the horse to stop with your seat. Allow your horse to spin until it stops. Remember, stopping is the only answer you will accept! Once your horse stops, get off and repeat this until the horse does not spin while mounting at all. Some food for thought:
this is the only method that works for my horse, and if I do not flex her she WILL walk off, every time. But I'd rather have a horse I need to flex each time than a horse who will take off on me. It's just become second nature when I get on her now.
Some horses might also respond to the 'backing' treatment, but I find it's really only effective if you're being incredibly firm - and have spurs on. You can try mounting, and if the horse walks off ask it to back up immediately, and quickly. You must be firm and reprimanding, so that the horse understands that having to back up quickly is a punishment for walking off. It's important when using this tactic to make the horse really MOVING its feet and working.
Just a couple of things that have worked for me in the past. Keep in mind these methods usually require repetitions to be effective.