I've run into the same issue. The first player to hit an other player seems to get the killcredit (till the killcredit cooldown is over) and if a new player hits the same player it doesn't overwrite the previous hitter. This issue only occurs when you use you leftclick/hit a player. When you hit someone with an arrow or with tnt that carries your UUID it does overwrite it properly and gives the last hitter the killcredit.
I can confirm this happenes in all 1.20+ versions.
It's mainly annoying when you play on minigames servers where you die often and when you respawn you have to enable sprint again.