Definitely one of those "how long is a piece of string" type questions. Far too many variables to offer a generalised definitive answer IMV.
Strings are an unscheduled maintenance consumable. Probably the most accurate honest answer for non-professional guitarists is, as frequently as you can truly afford to. i.e. someone who can afford to splurge on a couple of cups of coffee at Starbucks every week can afford to change strings once a month. It's a matter of triaging priorities. Every month is possibly overkill for casual home use, but will ensure acceptable tone and feel is maintained in most cases.
In the short time I've been playing, consistently almost every day over three seasons, my personal experience of both electric and acoustic strings ranging from cheap Chinese generic acoustic and electric through D'Addario EXL, Ernie Ball Slinkys, Mangan 9s and 10s or coated acoustic D'Addario EXP26 as well as uncoated EJ16 11s has observed that there is huge variation in string life and need to change, purpose dependent. i.e. for home practise, a duller sound per se need not define string change time in the cost:benefit equation, whereas for a gigging performer it must.
I've experienced cheap Chinese generics fitted to a new electric guitar which won't stay in tune within five minutes use! The solid G & B strings notorious offenders. Solution is to fit quality strings OOTB.
In my own case, I live in a very humid climate 150 metres line of sight from the Coral Sea shore where my home is immersed in either saline soaked 80% humidity stillness or a stiff saline sea breeze. I have air conditioning throughout, but of course, that's only on in summer months and weather, somewhat extended here. Humidity and/or salinity wreaks havoc on steel guitar strings. Surface rust will start to form on uncoated strings within days no matter how rigorously wiped or cleaned. A string lube is essential. My hands sweat too, so factor that chemical reactive effect in.
My qualitative determinent for must change is usually when they show signs of pitting, immediately apparent when they feel discernibly rough to the touch. i.e. they will literally shred fingertip skin. Before then the solid strings will have long visibly oxidised and blackened. The interim loss of tone is gradual, so not immediately apparent to my ears. Depending upon season, from fitment to practically usable (pit rust affected) takes about 6-8 weeks average, but in the height of summer can be as little as 4 weeks. Pragmatic ideal considering maintenance costs if owning a few guitars as I do now is to change monthly minimum, although in practice I confess to leaving it as long as possible, condition contingent. If I had just the one guitar, I'd probably change uncoated strings every three weeks in my circumstances. I buy my strings online in quantity to better amortise the cost. I've pretty much standardised on D'Addario as they offer optimum balance of all criteria for my use. Decent feel and tone, reliabilty, longevity, availability and cost effectiveness.
I've observed storing a guitar in a hardcase does result in a string service life extension departure from that norm, but most of my guitars live in the floor rack, floor stands or wall hangers which seduces me to pick them up in passing and play ad hoc frequently. Similiarly coated strings also fair notably better, but equally, the cost vs benefit doesn't justify using them to that objective. i.e. better off using EJ16s and changing twice as frequently than fitting expensive EXP26s.
For someone living in a climate like New Mexico, I expect the opposite would apply and they could expect exponentially longer life from their strings.