I like to believe that Ash's Pikachu's backstory shown in the first episode of Journeys, even if it was shown long, long after Ash and Pikachu even first became characters, is something that shines light on why he's the way he is in a few ways.
What little was shown suggests Pikachu was, for most of his life, alone, and learned to fend for himself even as a Pichu. The time he spent with the Kangaskhan family showed him what true love was, because one of the Kangaskhan adopted him and took care of him even though she didn't need to, even as it became harder and more exhausting to do so, and never complained about it because she cared. Pichu to Pikachu is a friendship evolution in the games, and in this case Pichu became Pikachu because of the love the Kangaskhan family showed him and how much he came to appreciate that love, even if he had to leave afterward.
I think Pikachu valued that time and learning what love is to the point where he hated the idea of being under a Trainer because the concept of being in a Poke Ball and being "owned" by someone was what Pikachu interpreted as a master and servant relationship with the Pokémon as the servant, and Pikachu was proud of how self-capable he was and didn't want to be anyone's servant. Which is why he didn't take well to being given to Ash at first and hated going inside a Poke Ball.
Ash won him over because he proved in the first episode that he didn't just see Pikachu as a "servant", but as a friend and equal. His heart shone through in how he himself was willing to go to any lengths to protect Pikachu, even at the expense of his own safety. That imo is what won Pikachu's friendship and loyalty, because that to him was the kind of love the Kangaskhan family showed him, and Ash right there and then showed Pikachu that same undying love and loyalty. That whole chain of events established them as true partners and equals that way. Ash will go out of his way for Pikachu, and Pikachu will do the same for him in return.
Pikachu, who lived mostly alone and yet learned what love is in a very specific way and came to cherish and want that, and Ash, who wasn't a conventionally "competent" Trainer, but who through his actions repeatedly showed that he loved Pokémon with all his heart. And it frankly couldn't have gone any other way with the two of them.













