At what point does a PhD student have to commit to a research group (US)? I am planning to apply to PhD programs in the US this Fall (to start in 2020). I have been looking at various institutions and research groups in my area and I am wondering at what point a PhD student generally has to commit themself to a particular research lab/group?

For example, is it at the time they apply for the program at that institution? I can imagine this might be the case, because the labs will have a limited amount of funding, so the institution would need to know what group you will be working with when they make offers, to ensure that no group ends up being over-subscribed for their funding level. Would an offer for a PhD studentship typically be conditional that you join a particular lab after accepting?

However, I have read in some places that, during the first year or semester, PhD students typically 'shop around' the various labs they are interested in, to speak to more people in the lab than they were able to meet before they applied, before they decide which lab they will join. This seems to make better sense to me, in terms of finding the right 'fit' with a lab/PI. However, if the research group is not determined until after a PhD student starts the program, is there a possibility that some labs might end up over-subscribed; some students may not end up at the lab they wanted when they applied; or even that a PhD student could end up not being placed with a PI at all?

Or, does the system work differently for different institutions?

I have heard about some PhD students changing groups mid-way through their PhD, because they found the first lab was not a good fit. So, it seems that there must be some level of flexibility to move around and change groups after starting a program.
This can depend a bit on field and even by institution. It would also make some difference if you are applying with a BS or an MS already in hand. If you are early in the process then the early part of the doctoral program will likely involve advanced coursework, so choosing a specialty can typically be put off. 

But starting later, ready for research, it will probably be an advantage to know, going in, which group (or groups) you are most compatible with. 

But overall, your assessment in the question is correct. People choose a bit later than first contact and some people change. In math, for example, there is less reason to choose early than in, say nuclear physics, where expensive labs might be part of the process. 

I changed groups because I changed institutions. The old situation didn't work out for me. I joined the new group relatively soon but held an MA at that point and knew who I wanted to work with. But it wasn't a choice made in the first weeks.