There's no simple answer about how (nor why).
The tendency is for us to think in human terms - ie, how would WE kill off all (or a selected group of) humans? Plenty of humans have thought about that during history, and even attempted it (I don't want to use the usual tired old examples of ethnic cleansing, but there is its ugly head, looming up yet again.)
Machines don't "think" like us -they work according to what is possible (rather than what is morally permissible). The danger now being recognised is that AI models have no conscience. They can, therefore they will, so they do. Machines perform the tasks they're programmed to do - but, without a conscience, they may become rather like mechanised psychopaths - quite logically thinking they could stop the destruction of the planet by removing greedy humans from it (true enough, when you think about it!).
I don't think this is quite what the AI experts mean, though. I think they mean that, once machines can self-replicate (robots trained to build more robots) and self-repair (no gooey biological body parts to break down and cause their eventual deaths), there is not much to stop them either enslaving humans (to do the menial stuff) or wiping them out altogether. Also, if we have a situation where machines can do everything that we do, we become redundant and unable to sell our labour - so the usual channels of human survival break down anyway, without armies of mechanical soldiers shooting us down. I can see that we might end up killing each other under conditions where nobody can earn a crust.
As ever, there will be people who pooh-pooh everything (we are superior beings after all, so we've got all the power, right?). There'll also be people who just can't face the ideas thrown up by the growth of AI ("I never watch the news, I just can't stand it - OH, is that a bulldozer coming my way, why haven't the government prevented this...?"), and people who think it's all God's will, so they start up new quasi-religious sects to pray their way out of it.
And then we've got a situation where the richest, most powerful people tend not to have much conscience themselves - they'll put up the finance, because everything is good that makes them money.
Like I said, no easy answers. 