Walt not being afraid to die =/= Walt is gonna actively put himself in harm's way.
If you assume Walt went there with the intention of killing Mike, then yes the scene is written sloppy and Walt's remorse in the end seems forced and tacked-on.
But this is "Breaking Bad", and the writers aren't sloppy.
So, no offense, but which is more likely....that they dropped the ball this late in the game, or that you misinterpreted the scene? Because if you read the scene as, Walt wanted praise or recognition from Mike, which they telegraphed from the opening scene, and the scene after that when he asked for a "thank you", and then again when he finally told Mike "you're welcome!"....then everything makes perfect sense. The ep is "Say My Name", the whole premise is, Walt wants props. He wants people on his dikk.
Lastly, you keep mentioning Mike has threatened Walt before, and Walt didn't seem worried last ep with a gun to his head....of course not, he had $300 mill worth of methylamine as leverage. Or he had Gale as a chess piece, or he had the security footage to distract Mike. Walt went into this final meeting with zero cards to play....it's far more likely he took the gun as "Mike might try to kill me, I better be prepared" instead of "I got a gun, I'm gonna kill Mike". Especially considering he could've shot Mike in the back....but he didn't, he said "you're welcome". Why? Because he wanted his props, not Mike dead.
Fred.