Andy McNab (Bravo Two Zero) has co-written stuff with Robert Rigby, McNab supplying the covert operations background and Rigby, the teen storytelling expertise.
On a very much smaller scale, I've co-written with my cousin. One of us will write a story and then submit it to the other, who can supply information and ideas that the other can't. For instance, if I have written a story about drug-takers in England, he would perhaps re-write the drug-taking passages because he knows more about that, and he might even suggest a different plot direction as a result of it. Similarly, I might re-write some of his 'England' sections (he's American) for accuracy. The story could go back and forth several times before we're both happy with it.
You have to be good friends, I think, and you have to have the same outlook on what you're doing in order for it to work.