Ultimately, Trump's "erratic behavior" is a social drama by a bully attempting to inspire fear for the purpose of gaining hierarchical dominance or profit. There is no case of Trump acting "erratically" for another purpose.
Trump is not going to war with anyone if he gets his payoff.
There are three other occasions where he acts erratically
-Someone or something is putting pressure on him (you can see this even before he went into politics with his bankruptcy or divorce proceedings making him act erratic. There is a whole saga of him trying to keep this big rich gambler gambling at his casino instead of going home with his winnings because of the financial consequences)
-He's reacting to an insult (real or perceived). Both before and after his political career you can see Trump is someone who takes personal slights to an extreme - there was one golfer who was down on his stats, Trump let use his courses for free. The guy practices and ends up rising back up and becoming a winner again. Trump asks him to wear a Trump branded t-shirt next time he played, and the golfer tells Trump he'll run it by his agent first. Not even a no - just a "I'll run it by my agent first." That was enough for Trump to ban him from all of his course. You can see it today with Trump tightening the screws on people like Elon Musk or British ministers for little reason other than they offended him
-He senses an opportunity for gain by making a huge spectacle. The last 3 RNC leadership contest, his near assassination, his court trials, post Jan 6th, really going all the way back to his TV career as a "strong business guy / wrestling guy" has been all about doing things as brazenly and large as possible, like a big American cheeseburger. He knows how to exploit the American news media entertainment cycle for free content