Our Gemara discusses what kinds of testimony is valid to establish lineage. The Gemara has much skepticism about individuals claiming certain lineage.  This makes me wonder, lomdus aside, why not trust a person who declares his identity, especially when in many situations of issur v’heter we trust a person's own testimony, even relating to their food or other personal halakhic issues? We have recently learned of many agunah situations where the rabbis made special exceptions to trust testimony of a single witness.  (Also see Chazon Ish EH 2:10 on the concept of shvach kehuna, who maintains that really medoraysa a person would be believed to testify about himself.)

However, human nature is not so straightforward. There are a number of Teshuvos dealing with people who fraudulently posed as cohanim (see Maharit 149, and Pisechei Teshuva Even Haezer 6:1).  In modern times, we have gentiles who successfully posed as rabbis, complete with imposter religious mitpachat-klad wives and families, even performing circumcisions! (Such as the infamous “Rabbi” Michael Elkohen https://nypost.com/2021/05/03/nj-man-identified-as-fake-rabbi-infiltrating-israel/ , who was actually a secret missionary with an agenda to infiltrate the Charedi Israeli world and evangelize.  He was successful for many years.)

The psychological urge to pose as an impostor is a theme that has repeated itself throughout human history, secular and religious.  There is a historically notable case of a man in World War II who posed as a doctor and even successfully performed a surgery on a submarine (https://en.wikipedia.org/wiki/Ferdinand_Waldo_Demara )!  There are hundreds of known cases of people in history who represented themselves as military heroes, royalty, oppressed minorities, etc. (See this fascinating list: https://en.wikipedia.org/wiki/List_of_impostors )

In the Jewish literary world, we have the subgroup of brilliant lamdanim who forged Sefarim. They produced entire works, claiming them to be lost manuscripts and even tractates ( see https://blogs.yu.edu/news/the-forged-yerushalmi-a-20th-century-controversy/ ) . What could motivate a Talmid Chacham to perpetrate and rationalize such deceit? (One of the most learned and famous forgers was Chaim Bloch. You can read about his story here :

http://judaicaused.blogspot.com/2018/10/fifty-shades-of-greatness-archive-of.html?m=1 )

What motivates people to commit such kind of fraud? I haven't been able to find solid research on this but I’ll take a stab on speculating and making a psychological profile:

The person must be brilliant and creative, but also impatient, as with all of his abilities, why would he not have just earned actual professional credentials? 

The person comes from a high achieving bright family, possibly with an overbearing and critical father. Thus, the incredible pressure to succeed mixed with anxiety, low self-esteem and perfectionism is a perfect storm for faking credentials or achievement. It is a psychological masterstroke of achieving multiple ends, and resolving internal psychological conflict. After all, such a person both reveres his father and hates his father. He craves his approval, but fears failure and criticism, and even if he succeeds he loses. Because if he succeeds,  he will feel controlled and as if his father won. So his success also spells loss of autonomy and self-mastery as it may feel as if he is living for his father. But If he fails, well, he still feels like a failure. 

On the other hand, if he fools everyone and achieves status and mastery by succeeding fraudulently in multiple careers, he accomplishes a resolution to the psychological conflict. He cannot really fail, because it’s fake anyway. He received adulation and admiration because people think he is a competent professional. And lastly, he passive aggressively achieves revenge against his father, and father-figures, by mocking true professionals and professionalism. 

Chazal had good reason to suspect strangers who come to town claiming lineage.