While he always talks tough regardless, I think his actions depend on the nature of the loss, e.g. him being all over the place on Iran, disregarding his own ceasefire for strikes and yet also heading towards a deal that's significantly worse than if he'd done nothing; or similarly all the everything in response to his threats against Greenland.
I interpret the same events you describe as Trump being unable to let go when he should have. Which is why he's made things worse than if he'd done nothing.