The first papers on using GPUs to accelerate scientific tasks came out at the turn of the century. Initially it was molecular dynamics, which led Nvidia to release their first scientific-focused line, the Tesla.
Then in 2010 or so, someone realized you could train a neural network very fast on these things.
The reason they are the leader here goes all the way back to the 2000s when they released CUDA. Because of that, the neural network (and therefore AI) ecosystem went with them.
Nvidia released CUDA in 2006-2007, which made that discovery possible, but Nvidia wasn't targeting AI with CUDA. It was targeting general high-performance computing (physics simulations, molecular dynamics, medical imaging, etc.).
There's no doubt the company seized on the AI opportunity superbly but the suitability of its product for AI, and the AI boom, was absolutely a "happy accident".