When feeling a strong urge to urinate humans tend to walk around when e.g. waiting for the current bathroom occupant to get out. Why is that?
This is what we call a displacement behaviour (or displacement activity, the term used by Konrad Lorenz - see below). Funnily enough, that's exactly the same general mechanism involved in the behaviour described in my previous answer here at Bio SE.
In short, a displacement behaviour is a behaviour that occurs when the animal (human beings are animals, of course) faces itself in a situation of conflict: you want to urinate, but you are inside a train, or in a concert, or in the theatre during the best moment of that movie, or the bathroom line is simply too huge.
In that moment, you realize that you need to hold it a bit longer. That's when you start your displacement behaviour.
When people need to hold a very strong impulse to urinate, the most common movements/behaviours are:
- stamping the feet
- walking, as you said
Therefore, walking is just one among several behaviours we show when we need to urinate but we can't: there is nothing special with walking in this situation.
Another common displacement behaviours that humans show in other situations are scratching the head, rubbing hands, drumming the fingers or biting the nails.
Konrad Lorenz explains displacement behaviours in his The foundations of Ethology:
When two conflicting motor patterns are activated simultaneously, it can happen that the organism performs a third pattern which may belong to an altogether different system. This curious effect was first described in avocets, Recurvirostra avisetta, by G. F. Makkink, the Dutch ornithologist who called the movements thus elicited "sparkling-over" activities (Über-sprungbewegungen). The accepted English translation is "displacement activities". Although "displacement" means something entirely different in the psychoanalytical literature, this term will be used here.
Further down, giving examples of displacement behaviours in human beings, he says:
Locomotion, too, is often disinhibited in conflict situations; some people tend to walk restlessly to and fro while delivering a speech, and so on.