Does this happen with medical students too?
No. Some medical schools (the most recent wave of new ones: Sunderland, Anglia Ruskin, Kent & Medway, Lincoln) aren't allowed to recruit international fee-paying students. For most others, the number of international fee-paying students is capped at 7.5% of their 2017 intake. (Their total intake numbers might have increased since then but the number of international students they're allowed to accept has not increased.)
This is complicated, though, by the recent emergence of some private medical schools that either only recruit international students at no cost to the central NHS (e.g. Brunel) or recruit any suitably qualified student who can pay the fees but, again, don't receive NHS funding in the same way as mainstream medical schools (e.g. Buckingham). However, these medical schools are accredited in the same way as all other UK schools and are in a position to take standard-funded home students whenever numbers are expanded.
I was encouraged to read recently that some British students are going abroad to study medicine, so the constraints that our our half-baked system impose on doctor supply are not an absolute blocker. I think people were going to Eastern Europe, or possibly one of the ex-Soviet republics, where apparently there are plenty of places in medical schools and local hospitals for trainee doctors. (I don't remember the details of how this was funded, presumably it is self-funded, but not expensive.)
But, of course, many of these were displaced by the war in Ukraine and have been unable to complete their training. Students who train in other countries have to go through an additional assessment before they can practise in the UK. From 2024 this will become the medical licensing assessment (MLA), which anyone who wants to practise medicine in the UK will have to pass, regardless of where they have trained (UK, Europe, rest of world). While this might - or might not - increase the number of medical graduates wanting to work in the UK, it doesn't do anything about the bottleneck of foundation training. At present, graduates have to complete a foundation training year before they are fully licensed and a second foundation year before they can enter specialist training programmes. Unless the number of foundation places expands (or the postgraduate training pathway is completely changed), it makes no difference how many medical graduates we have: they won't be able to work as doctors.
(I do not know who exactly is responsible for this. I don't think it's just the money)
Numbers are capped by the Office for Students on the instructions of the Department of Health & Social Care. DHSC attempts to match the number of medical & dental graduates to the number of jobs available to new graduates. Medical & dental schools that exceed the cap are subject to severe financial penalties.