Items different only in damage cannot be swapped
In an inventory screen, if you have picked up an item with the cursor and you click on a slot which has a different item in it, the two items are exchanged — unless the items differ only in damage/durability!
If such items were always swapped, then it would be much less tedious to swap out damaged tools for new ones.
(If I were to speculate about the cause of the bug, I would think that it is because the items look like candidates for stacking, and stacking does nothing since tools “stack to 1”. But that would be just speculation.)