Basically, if you hold a belt (let's say IBF, because they follow their own rules most often), then the IBF will rule that you must fight a mandatory defence every so often (usually about once every 12-18 months, unless your name is Deontay or Adonis).
If it's the IBF belt you hold, the mandatory will depend on the IBF rankings. A committee will meet once a month, and decide who to rank 1, 2, 3... etc. Whoever is number 1, will depend on quality of results (in fights the IBF has decided to watch), or if you're a sceptic, who's pushed the fattest brown envelope under the door at IBF HQ.
When the time comes that a mandatory is due, the top ranked fighter will take that spot (unless it's the WBC, then the number 1 gets shafted).
The IBF (for example) will say to the champion "fight this guy by this date, or we'll strip you".
Then, either the fight happens, and the winner keeps the belt, the fight doesn't happen and the champ gets stripped, or the champ pays the mandatory to take a step back, then fight doesn't happen and the champ still keeps his belt.
Mandatory just means compulsory. It's a fight you have to take, to remain champion... except it doesn't really work like that.
Understandable enough?
TL;dr - it depends.