WiFi doesn't automatically connect
Is there any battery saver/hibernator or such applications installed? 

There is a possibility of these apps turning wifi off, while you are not accessing any data(ie, if there are no active foreground apps using the wifi).

The next case i'm not sure about is Android Marshmallow's Doze feature.
I have seen people complaining about wifi being turned off, while doze kicks in.

As a solution, you can install any device automation tools like Macrodroid as mentioned in the comments above to tweak/bypass your problem.