I'm one of the few users here whose not taken in by the Elon hate-train and I often find myself here fighting against a windmill defending him against baseless accusations but in this case there's nothing to defend - that was a nazi salute.
Now, as to what he was thinking when he did that I have no idea. Maybe he still feels like that edgy 15 year old that he no longer is. In fact - kind of seems like he immediately regreted it and came up with the "my heart belongs to you" excuse. Either way, what was incredibly stupid and he should face serious reputational damage for it from his own side but probably doesn't.