There are several options with regard to the question of how to distribute students for face-to-face events.
Moodle already offers direct randomized, manual group creation.
In addition, there are the "Group Choice" and "Equitable Distribution" plugins for other types of group creation that can be created and carried out as activities in the course.
The "Planner" activity is similar in principle, only working with time slots instead of with groups.
This means, for example, that only a certain number of people are admitted at a certain time and that they may not be admitted to any further dates (in the same series of dates) even after they have been admitted, so that a fair distribution is achieved.