Compulsory and mandatory have the same meaning as in " (Something") must be done "
The meanings are very similar .
But, "of different reasons" why it must be done .
Compulsory show that it must be done or needed to be done because doing it is required or essential for something .
It is compulsory for you to bring your own books with you > it is essential /required of you to bring your own books.( for the lessons)
It is compulsory to wear jackets on Monday > it is reqiured to wear jackets on Monday
Mandatory shows that is must be done in order to fulfil a condition set by someone/something before something is possible.
Sportsmen must take the mandatory blood test to participate in the game.> they must take the blood test to fulfil a condition set by the organiser of the games.
It is mandatory to fill in all the questions > you must filled in all the quetions in order to satisfy the condition set by the asker
It is mandatory to wear your safety belts when driving ( it is what you must do if you want to drive (as it is a condition set by the government)
It is compulsory to wear a safety belt when driving > it is essential or required if you want to drive ( it is just required)
Compulsory > is required or essential to do
Mandatory > is required to do to fulfil a condition.