My personal experience is that it's a bit of both.
I am not a genius, but I can tell that I'm likely above average. I was raised in an environment that did not value intellect or education, and I always felt out of place. It definitely felt innate, and there are lots of stories from people in similar circumstances.
On the other hand, I never did well in school, especially math. One of my teachers literally called me stupid. So I had this self-perception of just not being very good at STEM. Had I not fallen into programming by accident, I would never have changed that perception of myself. I imagine there are very many people who had similar experiences, but were not so lucky as to learn their actual potential.
So, it's almost certainly a combination of factors.