I face the same problem. And I think I found out how to fix it. For the problem on my Samsung Galaxy A8, at least.
First type *#0011# on the Phone.
When you type the 2nd # the screen will change to ServiceMode.
Click More, and click WiFI.
Click the Ping Test button. The result should Pass.
And then restart the cellphone.
The WiFI should be able to turn ON/OFF without problem.
And to avoid the same problem to occurs again, keep the battery level. At least, never shutdown your phone without connected to charger.
Should this problem occurs again, just repeat the steps.
Good luck!