By Bruce doing a lot of work to integrate his two personalities at a gamma lab in Mexico
In She-Hulk: Attorney at Law S01E01 "A Normal Amount of Rage," Bruce reveals to Jennifer Walters (She-Hulk) that during the five-year period between Avengers: Infinity War and Avengers: Endgame, he worked on integrating his two personalities at a lab in Mexico built by Tony Stark.
Bruce: This is where I spent The Blip fixing myself and integrating
the Hulk-Banner identities.
Jennifer: In this tiny beach house lab.
Bruce: [Chuckles] Yeah. Tony built it for me a few years ago.
Bruce: Jen, I have been struggling with this for years. The best that I could do was merge my two halves. Give it time in the lab, we could possibly do the same for you.
Late 2019 | A Mindful Hulk
Dr. Bruce Banner turns his research toward fusing the two conflicting sides of his personality. After 18 months of experimentation in a gamma lab in Mexico, he successfully melds the brawn of the big green guy with the brains of the "puny human." He calls the erudite goliath that results "the best of both worlds."
Hulk can make small talk now.
- Marvel Studios’ Marvel Cinematic Universe: An Official Timeline
One of the techniques Bruce teaches (or rather, tries to teach) Jennifer on "how to Hulk" is dialectical behavioral therapy, which "allows [a person] to hold two opposing truths at the same time." This most likely played a big part in how Bruce was able to merge his two personalities into "Smart Hulk," or "Smug Hulk," as Jennifer prefers to call him.
Jennifer: Teach me how to Hulk, please.
Bruce: Dialectical behavioral therapy. It allows us to hold two opposing truths at the same time. First, we're gonna practice some mindfulness with a few yoga techniques.
- She-Hulk: Attorney at Law S01E01 "A Normal Amount of Rage"