My phone's wifi keeps switching itself off I've seen a few posts related to my query but none of the answers worked. I'll describe my issue in detail because honestly, I have no idea what to do anymore.

I have had the same problem before but it suddenly stopped and now it has returned. The wifi suddenly turns itself off and whenever I attempt to switch it back on, it just turns off again. I have restarted many times but it never works. 

I am using a Samsung galaxy s7 edge and the latest Android version. I hope someone can help, thank you.
In the WiFi settings, in the advanced tab there's an option that let's you decide when do you want the wifi to be turned on; make sure always is selected.

If that's not the case then you should better check your installed apps. An app (provided the right permission is given) can toggle the wifi switch.