I think it depends what country you are in, rather than what you are actually doing.
In the US, I find they are more inclined to say "excuse me" especially if they perceive you are in the way.
In Canada and especially the UK, people are more inclined to say "sorry" in each of these cases.
I also find that in Canada and the UK, people are more inclined to acknowledge that if two people bump into each other, both are probably at fault and so the polite thing to do is say "sorry" and move on without spending a lot of energy trying to assign blame to someone.
In the US, I find that people are very loathe to acknowledge that they have made a mistake and so say "excuse me" meaning "you have done something wrong and I would like to get by". On the other hand, when an American is clearly in the wrong, they will apologize profusely.
"Pardon me" is very formal and really should only be said to a judge in a courtroom!
In the end, there is no real difference between the words, it is all about your behaviour and how polite you are perceived.
Of course these are just my limited impressions.