It didn't even start with AI, their exorbitant valuations go all the way back to the days of the cryptocurrency mining craze.
But as a counterpoint: AMD is very similar but hasn't benefitted nearly as much. They've been plastering "AI" all over their webpage for years, with little to show for it. So maybe there was something that Nvidia was doing right.
CUDA is what they did right. That and they focused on developers (tooling, support, drivers) outside of gaming long before it was obviously a relevant market. Jensen does deserve a lot of credit.