It's because most people naturally go where they look or where their heads are turned. It takes practice and concentration to look one way and continue straight. All racers must practice this, whether runners, cyclists, motorcyclists or drivers.
Usually when I approach pedestrians from behind and there's any doubt about their intentions, I slow to slightly faster than their walking pace and announce "Bicycle behind you" in a conversational tone and volume. Then I move into the space they vacate, whichever way they go. Usually they move to the right.
If they're already far to the right and seem to know I'm approaching (if they peek over their shoulder, etc), I may pass slowly without announcing. Sometimes folks seem startled. Others have ear buds in and won't hear anyway.
And that works out pretty well most of the time. Once in awhile a fast approaching cyclist behind me or approaching from the other direction complicates things a bit, but I've gotten into the habit of passing much more slowly than I used to. I feed my need for speed away from the multi-use path. So when I'm on the MUP and trails I take it easy around pedestrians, joggers and slower cyclists. I can always speed up again after I'm clear of other folks. Good opportunity to sprint between those slowdowns, if I need to stretch my legs a bit.