20+ years ago, Python was popularized as a general purpose programming language, and was used as a systems programming language for tasks that weren't CPU intensive. For tasks that were CPU intensive, systems programmers, who were likely already familiar with C/C++, could easily dip into C/C++ and back into Python again if they needed to.
This made Python a good glue language, and cemented it as convenient scripting language that can be used to do things at near compiled language speeds. This quality made it a good choice for scientific programming, where resource efficiency and language simplicity are valued. In that domain, you could have large datasets that need to be analyzed by researchers who are not developers.
If we go back to late the 2000's and early 2010's, Python was popular as new programmers' first language, while they learned Java/C#/JS/etc for school or work. At that time, some of those languages didn't always have the modern pleasantries they have now. Python very much had the reputation as being "executable pseudocode" in contrast.
You had developers writing a ton of verbose Java, C# and JavaScript at work, but also had a preference for the simplicity of something like Python. You had new developers with Python experience under their belts, as well, as the Python community was/is very focused on helping beginners. When developers come from Spring to something like Flask, it can feel like a breath of fresh air, and it became popular in the web development space as a backend language.
On top of that, Python is older than JS and had a mature library ecosystem. If you needed to write code against an API, use an algorithm or data structure, someone somewhere probably wrote a Python library for it.
As a result, you had a lot of people saying good things about Python, using it in their free time, and contrasting the language with contemporary popular languages.
The data science and ML booms forced organizations to adopt Python if they hadn't in the past so they can work with data and models, and they were incentivized to publish their own Python libraries so that other organizations who adopted Python for the same reasons could integrate their products/services.