Magic!
Seriously, though, the bard knows how he does this even if we struggle to understand how it could be done. Lots of special abilities in a fantasy game are unexplainable. Nobody knows how to cast a fireball spell or turn undead either, and those remain an acceptable part of the system.
The real problem we have is when we read something like this...
Starting a bardic performance is a standard action, but it can be maintained each round as a free action. [...] A bardic performance cannot be disrupted, but it ends immediately if the bard is killed, paralyzed, stunned, knocked unconscious, or otherwise prevented from taking a free action to maintain it each round. A bard cannot have more than one bardic performance in effect at one time.
we actually have a frame of reference. Were supposed to imagine the bard rocking out on his guitar or singing "The Final Countdown" or tap dancing up a storm or miming being trapped in box or whatever while he's engaged in a life-or-death stabbing contest with a froghemoth? We read that and think, "No way. I know that's impossible."
But it's not for the Pathfinder bard. It's his way of life. It's how he survives in a world of monsters, wizards, and evil plants who want to eat him, turn him into a zombie, and make him fertilizer. That we don't understand how he can fight and maintain his magic performance in no way stops him from doing it because he's a magic dude in a magic world and this is what he does.
So, how does he do it? It really doesn't matter... in the same way it doesn't matter what the exact syllables are for fireball or exactly how much faith one needs to turn undead. He makes magic happen when he plays or sings or dances or mimes, and he can fight while simultaneously playing, singing, dancing, or miming. And that's hilarious, and it works.
By the Rules
The primary objection raised is that, in real life, musical instruments usually require, well, hands, and if a bard's hands are full he shouldn't be able to perform on that musical instrument. First, this is why most bards sing. But, moreover, Pathfinder doesn't mandate hands are necessary to employ any bardic performance; performances are audible or visual or both, but no mention's made of requiring hands. The skill Perform doesn't say instruments require none, one, or both hands. Even the entry for musical instruments in the equipment section is silent on whether instruments require none, one, or both hands. The game is so hesitant to get specific that musical instruments are almost completely abstracted; we're told the only difference between a hand bell and a pipe organ is that "larger instruments... are of course larger and more expensive." Really. Nothing else is said.
Thus requiring the bard's hand or hands to be occupied by his instrument while he employs a bardic performance is a house rule.
I imagine that a combat musician who plays guitar or something when fighting monsters probably keeps his instrument on a sling and strums it when he wants magic to happen or needs magic to continue, but spends the majority of his time swinging his sword.
Barring that, it's possible a Pathfinder musical instrument is designed to be played as a free action while wielding a magic rapier in one hand and carrying a flask of alchemist's fire in the other, and we--as folks who don't require this of our musical instruments as we're not spellcasting musicians who fight monsters with music--have no concept of what such an instrument even looks like, much less how one's actually played.
There's no way to know what the Pathfinder bard's doing during that free action to maintain his song because the whole event takes place in a fantasy world where magic exists. The only thing we know for sure is that the bard does, in fact, do it that way because the rules tell us he does.