Instead of dropping the Sword of Gryffindor, Harry swings it at the incorporeal Tom. Magic does what magic wants, and instead of getting destroyed or simply going right through, the sword absorbs Tom’s soul. Now, if that was the only thing that happened, it wouldn’t be so bad. However, the sword now being held by Harry who also has a piece of Tom’s soul causes them to “bond”. Now Harry can’t be more than 50 meters away from a talking sword who has the attitude of a teenage dark lord.