It's correct English. Are you sure you know what it means?
"Education is necessary" means that everyone needs education.
"Education is mandatory" means there's a law or rule saying you must have education, and you will be disciplined or punished if you don't get it.
For example, to drive a car, practice is necessary, and a driver's license is mandatory.