Are professors obligated to accept supervisory role? If not, how does it work?
The exact answer to this is likely to vary from one university to the next, depending on local rules and terms of employment. In general, the position is likely to be: professors are not required to agree to a student's request for supervision. However, it is generally advisable/mandatory for professors to accede to 'requests' that come from higher up in the management hierarchy.

If students are required to complete a supervised project as part of a course, then it is the university's responsibility to ensure that an appropriate supervisor is made available. If a student reported that they cannot find a willing supervisor, this would likely result in management applying increasing amounts of pressure and/or incentives until someone agreed. However, in such circumstances, the student is likely to be left with Hobson's choice - the project offered may not be a close match to the student's preferences.