I play guitar as well as bass, and have for over 30 years. This is not my experience at all. A well-maintained guitar with a good setup does not go out of tune all the time, nor should that be expected. More often than not if someone's guitar is going out of tune all the time, there are issues with setup, or there are problems with quality or maintenance of components. I've improved the tuning stability of some nice guitars more than once with quality machine heads. I just recently replaced the stock strat tuners on a guy's guitar with locking Gotohs, and he can't believe the difference that made in tuning stability. That, and his strings were twisted in the tremolo block, so each time he bent it down, they would untwist and impact his tuning. Good setup and tuners made all the difference.
I don't mean that a well-maintained guitar with a good setup goes out of tune all the time, more that it happens live and it's almost impossible to avoid without affecting your playing style. A guitar that sits in a studio or at home is more or less in equilibrium with itself and will be fine. I've picked up guitars that sat for months indoors and stayed in tune.
Locking tuners, in my experience, do more for making string changes quicker than they actually improve tuning stability. The nut, bridge saddles, and cutting your strings properly do more for tuning stability than locking tuners do. Unless, of course, your tuning machines don't work properly, but almost all of them do.
Live is a different story because your guitar hasn't been there long enough, hasn't adapted to the environment, and then as soon as stage lights or fog machines come on, and your hands reach stage temperature, now your guitar is in a completely different environment than before and will take time to stabilize, which will not happen in your average live set. Perhaps the only way to control that is to have doubly locked guitars, as I mentioned.
You can also play heavier strings. Never use a capo. Never bend. These things will allow your guitar to play longer in tune. But then now you've changed your playing style. What's even the point of that when silent tuning pedals are a thing and you can quickly adjust your tuning? I mean, that's what they're meant for. I can often tune without disrupting the flow of live sets, often in parts of songs when I'm not playing.
If you watch classic footage of great guitar players and really listen carefully, you can hear guitars going out of tune. A good guitarist is sensitive to that and will tune guitars before the audience notices it. It then looks like he or she is doing just to do it, but it's for a good cause.
And honestly, it's like, to some extent, who cares if guitars go out of tune? For instance, look at Jimi. He is always out of tune. So what? Would you rather that he had played safely to avoid that?