Horatio asks Fortinbras to put all the bodies on a stage and then Fortinbras specifically chooses Hamlet to be taken – by four captains, no less. He does not even know what happened yet. Hamlet could have killed all the other people in a mad sociopathic spree. Fortinbras has literally no idea. He happens to choose the guy who we’ve been rooting for this whole time – but he could just as easily have chosen Claudius to bear to the stage like a soldier. Claudius gave him permission to troop through the country, after all. He could have been the soldier’s choice for an honorary soldier.
I suppose, depending on the arrangement of bodies when he enters, Fortinbras might be able to see that Horatio’s loyalty is with Hamlet. If, for example, Horatio is cradling Hamlet’s body – and Fortinbras is reading the room through Horatio, he could be making this call on physicality. Or else he’s just read the title of the play and he knows what side his literary toast is buttered on.