Dogs are descended from wolves and maintain certain of their ancestors' character traits.
Wolves are very hierarchical, every wolf in the pack has a rank and place, starting with the Alpha Wolf. Oftentimes the Alpha will daily assert his dominance. They do this in a variety of ways, anything from growling, attacking, or mounting other wolves in the pack. You will even see female wolves mounting wolves of both sexes.
There are also numerous ways for wolves to show their submission to those higher up in the pack. They will roll over on their backs, expose their throats, cower, and urinate. The ones that cower and urinate are the most submissive... one look from a higher ranked pack member would be enough for this sort of submission.
So, basically, the higher strung and jumpy a wolf or canine is, the more likely they will do submissive urination. In the case that you describe, the dog literally had the piss scared out of him. Fight or flee is how most animals react to a bad situation. He couldn't flee and obviously is not a fighter. Even though you were trying to help him, there was no doubt within your voices your own panic at the concept of a laptop being destroyed and then urine everywhere.
What can you do? Well, you describe this as though this is the first time it has happened. If so, these things are bound to happen every once in awhile, so just go on as normal and accept it.
If it's happened regularly, you need to learn to adjust your own reactions to these situations as the calmer you are, the calmer you can make the dog. Animals pick up on emotions far better than humans can sometimes, so if you panic, he will panic. If you're calm and soothing, the dog will be more responsive.