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.