Good point Herb.
Another thing string gauge has a lot to do with staying in tune. The thinner the gauge the more likely that it will go out of tune. My 8-38s on my tele goes out of tune a lot faster and easier than my 13-58 flat wounds on my jazz box.
Another thing I have discovered through the years.
Absolutely, the thinner the gauge set, the easier it is to pull it out of tune. But even beyond the simple issue of gauge size....
Certain brands of strings seem to hold tune better than others. They are not all made alike.
Through the years, I have tried many different brands and gauges. When the gimmicks came along, yup, I bought some of them too and tried them. I always tended to keep coming back to one particular brand and gauge.
I even gave away a bunch of those brand new string sets to some guitarists who I knew didn't have a lot of money to buy strings because I didn't like that brand when it came to live performance and reliability. They were appreciative, and I got rid of the strings I would not use on stage.
Another string related issue to consider.
Strings have a time window during which they stay in tune fairly well. When they are first put on, they need to be stretched in....(broke in) ..... normally, I could install a new set of strings and in 20 minutes have them stretched sufficiently to play a set with only a few tuning touchups during the set. I kept my conn strobe tuner plugged into the line level out on the amp for tuning as needed while playing.
Once they are broke in, they will hold fairly well for quite some time. As the string get played, they start to wear on the underside from being pressed against the frets. Those wear points can be felt when you slide your finger down the string underneath it. That you can feel it indicates that the diameter of the string is different at those points and that affects the intonation of the string.
More than one time I've had tuning and intonation issues. A simple changing of the old strings and replacing them with new strings solved the problems.
Another thing: I never simply change one string. It's always a complete set swap. If that one string broke, that means all the strings are the same age.....probably going, or already dead..... so change them all. When I played on a regular basis and made my living from it, I would keep a spare set for breaks in a show. (I would also keep a second guitar handy.) But at the first chance, I'd change the rest. Knowing the average life of my chosen brand, I would change the strings on my guitar on a regular schedule. As a result, I rarely had one break in the middle of a song.