For me, it's about five years for my main machine. This doesn't include Macs I buy that are broken to tinker with, fix, and resell, Macs I've bought for family members, or any Mac I keep as a backup machine.
I like to keep my Macs for as long as possible but not too long before they will have difficulty running my workload. For me, the M series chips has completely changed how long I feel like my Mac will remain viable. I think they will last much longer now.
My daily driver is a 14-inch M1 Max MBP that is awesome. It's the most expensive computer I've ever bought but has served me very well over the past 19 months. It's docked 90% of the time and it always amazes me how quiet and yet efficient and powerful it is for my workloads while running two external monitors and the internal display. The only time I ever hear the fans is when I'm rendering a video or playing a game, both of which are only a few times a month.
With the way this is performing for me, I'm confident it will easily last me until late 2026, which is when I might start looking to buy a new one. My last MBP was a 2016 non-TB 13-inch MBP which I used for five years without issue until the display died. Moving from that dual core to the 10 core M1 Max was such an awesome power boost. Before the 2016, I had a 2012 15-inch MBP that worked great for four years (and looking back, was much more versatile than my 2016 and I should have kept the 2012 longer).
I also recently picked up an M1 MacBook Air on sale. I've been traveling a lot more recently and while I find my 14-inch MBP very portable, I don't need all of it's power when traveling. Given how much I paid for my MBP (I know, it's not worth that anymore), I'd also rather not have it lost or stolen. The M1 Air is a perfect traveling Mac for me. It's powerful enough to handle everything I need while traveling, but also wasn't so expensive so I won't feel as big a dent in my wallet if it's stolen.
Sometimes I feel a bit silly having two laptops and have thought of maybe replacing my 14-inch MBP with a mini or Mac Studio or something. But I don't think the benefit would be worth the time and cost so I plan to keep this two laptop setup for some time, at least until 2026.