Mandatory means that it must be done. There is no option.
Its not optional, You have no option not to it
It is when you have got to be somewhere when you do not want to be, or do something that you don't want to do but still have to. It just doesn't sound right, but that is the way it works.
It means "compulsory". You have no option to NOT do it. For example you may have a mandatory training course on your employer's Fire evacuation procedure. You HAVE to attend, it is not optional.