I'd not completely discount degrees, sure it's less important for general programmer positions and you don't necessarily need a CS degree for those, most employers are quite happy with any STEM degree for those sorts of roles but for some more quantitative roles, it's super useful. It's easy to pick up programming skills by yourself but it's not so easy to pick up advanced mathematical skills, better to get those sorted before your early 20s as it's also generally considered that they're harder to learn after then too.
For example, traditional quants and quant developers in banks through the 00s required maths, programming and finance knowledge, banks invariably preferred to hire people with formal training in applied mathematics for these roles (basically mathematicians and physicists) as they could easily pick up the required programming and finance knowledge. The converse isn't true, the average programmer or finance person can't easily pick up solving PDEs, stochastic calculus etc..
AI/ML is the big thing for ambitious people with good quantitative skills now, traditional derivatives quant roles aren't as in demand, the models have already been created and banks are not as appealing as landing a role at Google, Meta etc.
Jobs in that sector that require or desire PhDs are research roles and do so because that's the way most researchers learn, a PhD is basically an apprenticeship for a researcher. Some PhDs might work in non-research roles, academia didn't work out for them so they become say a programmer or take a data science role that only really needs a masters level education.
In theory, you don't need a PhD to do research, some researchers (including some university researchers and professors) don't have a PhD but it's rare, the issue is how do you demonstrate to someone employing you to do research that you're able to do research? That generally requires some mentorship as a PhD will offer and existing publications. There's a famous guy in Berkley who is passionate about AI safety, he runs a research institute and has no formal education IIRC, he's an exception though.
Likewise, for roles that require or desire an undergrad or masters degree, you don't necessarily "need" one but you do need to have some way of demonstrating you know the stuff needed - it's not like there are formal restrictions in place, in theory, someone with no degree at all could become an ML Research Engineer perhaps if they taught themselves the necessary undergrad level mathematics and then perhaps became known by others in the industry through open source projects, Kaggle, social media presence etc.. they could get referred by an employee at a tech firm and interviewed.
Though if such a person were to go to that much effort and study all that stuff then why not claim a degree for your efforts (even if just a part-time one). Basically if looking to do anything mathematical/quantitative then some formal education in the form of a maths-heavy undergrad degree is very useful!
Programming/CS stuff, practical skills like scripting etc.. all that stuff can be self-taught/learned on the job (though most quantitative degrees will have at least some programming requirements even if it's just R, Matlab etc..) mathematical maturity though is much harder to develop later.