Thanos is a Titan and half Eternal. They are super strong and resilient.
Also, it's a movie, and drama trumps realism. He was as strong and as weak as he needed to be for maximum dramatic potential. Creative writers try their best to balance the drama and realism, but it's not an easy thing to do sometimes. In Infinity War, the Avengers were at their worst. Splintered and unfocused. In Endgame, they were unified and determined. The writers found ways to handicap them so they wouldn't steamroll Thanos. Thor caught him off guard with Stormbreaker, otherwise, I imagine he'd have whooped his ass too.
Extra also; power levels are stupid. When handled poorly, it sticks out. When handled properly, most viewers that aren't super pedantic and nitpicky can just run with it because the story being told is entertaining them. "Power levels" is just another tool in the writers toolkit when creating stories. Superhero stories can be annoying to write because of it. I try to at least have my heroes win against powerful foes through means beyond just "I hit harder than you, because of POWER LEVELS!" or finding the power of friendship and going Super Saiyan because I've written myself into a corner with an antagonist that is just too strong. Then the next threat has to be even stronger, so they have to power up beyond that threat, then the next threat has to be stronger than that, etc, etc. It's exhausting.