In the story where David acts like a madman in front of a Philistine king because David is so evil that he’s actually less threatening that way, it says the king in question was Achish of Gath. But in the note at the beginning of a psalm that David supposedly wrote at that time, it says the king’s name was Abimelek.
Possible explanations
Maybe the king had two names. Or maybe David fooled multiple people the same way.