Anyone who reads The Unbeatable Squirrel Girl knows that not only does she have superpowers (including super strength, super agility, claws, tail, knuckle spikes, ability to command a literal army of squirrels, ability to communicate with said squirrels, and some measure of invulnerability), she is also extremely intelligent (a computer science major who keeps up with her studies in addition to superheroics), pretty much angst-free (so not handicapped by her own emotions like so many superheroes) and, most importantly, she is allowed to have common sense.
Common sense is something most superheroes and supervillains lack. She defeated Doc Doom twice by a combination of superpowers, intelligence, and sense. Take any one of those qualities, especially sense, out of the equation, and you have a bog standard superhero or supervillain who does typically dumb things to advance the plot. She is one of the few who is allowed to use all those positive talents in the same altercation. If she can talk 'em down, she does. If deliberately losing the battle means winning the war, well, she's done that, too. Usually she just has creative strategies combined with intelligence, powers, and sense.
It used to be a common joke for a while that she beat the biggest of the big bads off-panel, though in her own comic we see her methods, which are sometimes conventional and sometimes quite wild and out there. I imagine she beat Thanos because he got arrogant and over-confident, she got sneaky, and the squirrel army swarmed.
It's worth mentioning that later, in another comic, Thanos claimed she only beat a clone, despite what the Watcher said. Who are you gonna believe? The Watcher or the villain with the bruised ego? LOL. (Clone jokes come up frequently in TUSG comic, ridiculing this very bit of Thanosian ego)