I bet there's some sort of logic on google's side that states, if a government homepage url redirects to another non .gov URL, that the .gov address should be the canonical page of the site thats being redirected too. Which would explain why stackoveflow's homepage isn't listed in the results. Just a guess.
I could imagine the ranking favours .gov domains, which should be reliable. But surely for anything Google sees as a redirect, the redirect target should be the canonical URL?