Here's the way I read one STEM department in the US that I have some insight into, but I'm also reading this through third-party comments and the experience of a few students I know, so take it with a grain of salt. RAs go to professors who have grant funding or startup funding to support them. If a student is admittable, but no professor puts their hand up to say they want to support them on an RA, then they may or not be actually admitted depending on how many TA slots are available and how the committee feels about them otherwise. There may be a handful of department-level or privately-funded RA fellowships available for really great students. Some students may be admitted with no funding, though I think this is unlikely for students explicitly applying for PhDs (more below).
I know of two separate cases where a student was rejected when no professor was willing to stick their hand up and offer them an RA during the committee meeting. In one of those cases, the student was admitted the subsequent year after publishing a few great papers and making a few contacts. The other student decided to do his PhD at another nearby school. I don't know what drives this difference between TA and RA admissions in this particular department, but it seemed clear that if you have someone who wants to work with you, you can surmount many admission obstacles, assuming they have funding. Not having a champion can also scuttle your chances. I think that some really top notch students must be "claimed" by professors based on their applications only, that is without prior contact with the prof, but I can't prove that and don't know how it works.
My strong impression, but more speculatively, is that some students are admitted to the master's program with no funding hoping to score a TAship along the way or impress a professor in one of their early courses and land an RA. After that, being admitted already, they will try to upgrade themselves to a PhD student along the way. I think a lot of the TA positions go to these students. This latter impression is based on the huge number of requests for RA positions I get in a non-academic research organization every year from MS students with no apparent funding.
Now with all that being said, students coming to this department with master's degrees already in hand appear to be at a disadvantage unless they have very strong CVs or prior contact with a prof that wants to work with them. That was the case with the two students I mentioned before.