The enrolment type feature lets you set courses as either mandatory or optional. It isn't switched on by default, so you'll need to request it for your account before you can use it.
How to request the feature
Ask for enrolment types to be enabled for your account:

