People get credit wrong for many reasons. Here’s a few:
Cryptomnesia is when a person has a memory of an idea they doe not recognize and perceive it as their own.
Sometimes discovery is incremental and dispersed, and the people who go the last mile get the credit. See CRISPR Credit
Sometimes the marketing of the invention fails, and better marketed attempts that come later are identified as the prominent. See Kenbak-1
Sometimes the most prominent instance of an idea gets the credit, as in wiki/wikipedia or the Rio/iPod issue.