I think the trope is an exaggeration of something that does kind of happen in real life, where being a lonely kid at school, you latch onto basically anyone who is friendly or at least not directly hostile to you, or is willing to hang out with you because of a shared interest.
Like my "best friend" aged 11 was a girl from my form in school who has also isolated for being kind of this... swotty little underdeveloped oddball, so we stuck together, but I don't think we actually liked each other, it was just better than being alone and offered a small amount of protection against bullies.
Due to the relationship being effectively one of convenience or very shallow attachment, it's not unusual to end up hanging out with someone who is... honestly kind of a weirdo, and not to mention, people can change a lot between the ages of 11 and 16, so you can easily make friends with a sweet innocent little dork and have them turn into a snarky horndog and still find yourself friends with them out of habit.
That said, it's really really possible this trope is dated as hell because when I was in my early teens, it was still the nineties. You couldn't just go find communities of people who share your interests on the internet. It was really lonely being geeky back then, and if you found somebody else who was at least willing to listen to you talk about Dungeons & Dragons, oh my god, wow! An oasis in the desert! So creators have probably written this trope based on their own experience, and then younger creators often copy tropes they like from comics they've read by older creators that don't in any way reflect their own lives.