/loot command puts item in helmet slot instead of hand.
While running (/loot) command, the loot items are replaced in different slots (slot.weapon.mainhand ; slot.weapon.offhand, etc.) Even when running to set loot in an specific slot.
Eg: While using the /loot replace entity @s “slot.weapon.mainhand” 0 loot "chests/ancient_city" ,
The loot replaces in Helmet Slot, Offhand, Leggings slot.
The command:
/Loot replace entity @e/a/s/p (any slot) (slot number) loot/kill (entity/chest ; structure/entity)