It’s difficult to switch residencies because each residency program has a fixed number of positions per training year which is largely funded by the government. And almost all positions are filled by the end of match so the only way you can switch is if someone leaves their position for some reason and they happen to be at the same training level as you.
Medical schools admit a variable number of students each year although they aim to have a specific number. It’s difficult to switch medical schools because Med school curricula are very different from program to program. And also there’s just no standard mechanism for switching, you’d just have to schmooze some of the higher up administrators. Med schools don’t really get any advantage by taking in transfers unless they had a mass exodus of students and needed the money. So there’s little incentive for administrators to even bother with transfers. In residency you want all your positions filled so you can keep the funding and have enough staffing so if a position opens you want to fill it ASAP.