You are right that it is partly in the culture, but you paint with too broad a brush about masculinity being a major driver. Of the gun people I know, few imagine getting into a gunfight. Most consider it a hobby that also enhances their ability to defend themselves.
But we also know that the defensive use of a gun is a horribly serious thing to do, with potentially very bad consequences. Gun training emphasizes how to avoid dangerous situations, especially the training for first time gun owners.
I started with guns when in high school in a mostly rural midwestern state. It was a thing we did for fun, or for hunting. Then I went decades without firing a gun - so much for the machismo. Now I shoot regularly with a small caliber gun (.22) as a sport. I occasionally will use a self defense weapon at the range, just to stay competent.
But the image of Americans carrying guns for machismo applies to a small number of those who carry guns, and a smaller percentage of those who own and shoot guns (not every shooter carries).
By the way, I once had to fire a gun to defend my life. It was not a decision taken lightly. And, like most defensive uses of firearms, nobody got shot - I was able to drive off the very real threatening gang (my friend was in the hospital at the time after being severely beaten by them) with warning shots, thank goodness.