Bethesda obviously meant for you to go with Ralof and not Hadvar. This is easy to figure out when you look that how much light imperial armor is worth vs stormcloak armour. So killing Imperials is far more profitable than killing Stormcloaks. Plus there is that chopping my head off business. Shoving a blade into that Captain feels goood everytime.
To answer seriously though, I don't think any character would overthink such things at the time. Chaos, confusion, you can't find the keep, the only nice Imperial you met so far showing you the way I can see how a character could just stick with him. And also, he doesn't attack Ralof and the other Stormcloaks or even make alarm at the keep so he's not out to win any merit badges by rounding up anyone.
I can see people's logic behind Hadvor, as he does make it clear he'll protect you, however, I'd have had no way of knowing if the Captain along with her lackeys would have been waiting to grab/kill any prisoners that came their way. The Captain had no interest in my survival prior to the attack, in fact, quite the opposite and it's obvious only her opinion mattered. She had already dismissed Hadvor out of hand, so I think it's safe to assume it would only have been a matter of time before i had either been killed or executed.
Someone else in the thread made an anology between the in game situation and a real life prison break, stating would i go with my fellow inmates or go to the guards, with the possibility of getting a pat on the back for not escaping when i had the opportunity to do so. of course I'd opt for the latter, however, our judicial system doesn't work on a grab 'em and chop 'em basis.
A better anology would be a WW2 prisoner of war camp, where you're not given any trail, hearing or justice. In this case they just want to torture or kill you regardless. No matter what crime my fellow prisoner had committed, we're united in one cause and that cause is to either survive or to escape. until i escape i share nothing in common with those trying to execute or hurt me.