WiFi doesn't automatically connect I have a Nexus 5 running Android 6.0.1, not rooted. 

When I travel from one known WiFi network to another (possibly even am inactive at home), the phone does not automatically connect to WiFi. When I check the settings, WiFi is turned off. When I turn WiFi on, it connects happily. The WiFi signals are strong. 

In the settings menu for this phone, I have gone to Settings -> WiFi -> (top right menu) -> Advanced -> "Keep WiFi on during sleep", and turned this on. It has been on for weeks, and still the phone turns WiFi off. 

Question: How can I prevent Android turning WiFi off? 

Due diligence: I have checked the forums, and nothing seems to solve this exact problem. (The setting above is mentioned as a solution. I wish it worked.) Also, few posts are recent.
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.