Historically, Python always had an amazing Math/Scientific computing package/libraries, and many of the python syntax (e.g. list comprehensions) reads like typical mathematical formulas, and python can handle big numbers natively. So it is often the preferred language for Mathematicians (when they want move beyond Matlab or R). And a lot of machine learning is basically Math. So a lot of researchers (who usually have stronger math background) uses Python to experiment with ML algorithms, and sometimes creating the initial libraries in ML. (although after algorithms are proven to work, the algorithm often are rewritten in more efficient languages like C++, but they still often kept the Python interfaces).
For comparison, for history of Javascript, it is originally intended as a quick and simple script thing for running inside browsers to manuplate the DOM, and only in 2009, with NodeJS, people started to use it for backend.