So on occasion, my wifi automatically turns itself off for some strange reason. This happens on both my Lenovo ThinkPad and my Samsung Galaxy S5. Is there a way prevent this from happening?
You can turn off the Connection Optimizer, if it's on.
Settings → More Networks → Mobile Networks → Connections optimizer → Turn off Connections Optimizer, or turn off Wifi Timer
Settings → Wifi → Tap the vertical ... and then Advanced → Wi-fi Timer → There turn off any timer selected.
I hope this works for you.
In Wireless options in your Samsung device. Click on options (Overflow-icon) and click Advanced. After that you'll see an option called "WiFi timer", click on it and uncheck both check boxes.
Does this happens on your devices who are connected to the same network or? And does it happens on your, or any network.
And here is the link from Lenovo Support page, about your problem.