It attached itself to Harry because he was the only living soul.
The piece of the Dark Lord’s soul embedded itself in Harry because Harry was the only living soul in the room. Disembodied souls naturally only would be able to stay in other living things. They’re only able to stay in inanimate objects when they’re deliberately sealed into them by the spell used to make a Horcrux. The piece that broke off of the Dark Lord, however, wasn’t deliberately encased in anything, so it stuck itself in the only living soul nearby.
“Tell him that on the night Lord Voldemort tried to kill him, when Lily cast her own life between them as a shield, the Killing Curse rebounded upon Lord Voldemort, and a fragment of Voldemort’s soul was blasted apart from the whole, and latched itself on to the only living soul left in that collapsing building.”
- Harry Potter and the Deathly Hallows, Chapter 33 (The Prince’s Tale)
This bit of soul is different than a Horcrux, because in making a Horcrux, the wizard creating it intentionally encases it in an object using a spell. Pieces of soul don’t naturally attach themselves to inanimate objects, they tend towards wanting to embed themselves in something living.
“Killing rips the soul apart. The wizard intent upon creating a Horcrux would use the damage to his advantage: he would encase the torn portion –’
‘Encase? But how –?’
‘There is a spell, do not ask me, I don’t know!’ said Slughorn, shaking his head like an old elephant bothered by mosquitoes.”
- Harry Potter and the Half-Blood Prince, Chapter 23 (Horcruxes)
The other instances of souls finding new hosts indicate that it’s much easier for soul pieces to enter living hosts on their own, without the magic required to seal them in an inanimate object. Even pieces already sealed in a Horcrux can temporarily possess living people. Though the soul piece in a Horcrux is dependent on its object, it can still possess other bodies, though not objects.
“The bit of soul in that diary was possessing Ginny, wasn’t it? How does that work, then?’
‘While the magical container is still intact, the bit of soul inside it can flit in and out of someone if they get too close to the object.”
- Harry Potter and the Deathly Hallows, Chapter 6 (The Ghoul in Pyjamas)
When he was ripped from his body, the Dark Lord could also possess bodies, of humans as well as animals. He likely couldn’t possess inanimate objects, though, it seems limited to living bodies.
“Only one power remained to me. I could possess the bodies of others. But I dared not go where other humans were plentiful, for I knew that the Aurors were still abroad and searching for me. I sometimes inhabited animals – snakes, of course, being my preference – but I was little better off inside them than as pure spirit, for their bodies were ill-adapted to perform magic … and my possession of them shortened their lives; none of them lasted long …”
- Harry Potter and the Goblet of Fire, Chapter 33 (The Death Eaters)
This also explains why the piece of soul didn’t just reattach itself to the Dark Lord - he was ripped from his body, so at that point he provided no body for the soul piece to attach to.
“Aaah … pain beyond pain, my friends; nothing could have prepared me for it. I was ripped from my body, I was less than spirit, less than the meanest ghost … but still, I was alive.”
- Harry Potter and the Goblet of Fire, Chapter 33 (The Death Eaters)
Therefore, the piece of soul that fractured off the Dark Lord’s couldn’t attach itself to an inanimate object, and it couldn’t reattach to the Dark Lord as he was bodiless. Harry was its only choice.