Everyone deals with depression differently. Thor just took it much harder than everyone else did. I don't see that as a bad thing. Do you really think he'd just snap out of it (no pun intended) incredibly quickly and just be back to the old, enthusiastic Thor within days? Speaking as someone that definitely has suffered from severe depression, it takes time to get out of that hole. We don't see much of him post-killing 2012 Thanos, so that could have very well been the catalyst that brings him back to the Thor you want him to be. There's also just no way to know how he feels internally. It's easy to give a brave face on the outside and still be very depressed on the inside. I've been doing it for years, so I know.
You may be remembering Ragnarok wrong. In the beginning he's still the same Thor he always has been, talking shit and joking around with Surtur. He only really starts to get down after Mjolnir gets destroyed (as it's the one thing he's had with him through just about every battle he's ever fought), and he's not used to being without it. That's why it takes the pep talk from Odin about being "Thor, god of hammers" before he starts to realize he's more than just Mjolnir. He finally gets some semblance of his confidence back, and then immediately loses Asgard and most of it's people. That is relatively quickly followed up by Thanos appearing and killing the rest of the Asgardians, as well as his brother in the beginning of Endgame. That's his third major loss in about a year (I don't know the time frame between the end of Ragnarok, pre post-credits scene and the beginning of Infinity War).
He seems to get some confidence back when they travel to Nidavellir and he builds Stormbreaker, but then is thrown another big defeat when he fails to kill Thanos by not going for the head. Less than a month later, he fails YET AGAIN to bring back anyone Thanos killed with the snap. This all takes place within the span of maybe three years? All of that shit going bad quickly after most likely hundreds of years of victories is definitely gonna affect someone pretty harshly.