It varies.
I had (and still have) a 2008 Mac Pro running as my main machine for ten years. It still works, with dual boot; Snow Leopard and Sierra. Proves to me my thesis that a big investment often can prove a good investment because it will last long. With some SSD and graphics upgrades, it still performs pretty snappy.
Then I got into a testing period going thru an iMac, then Minis; i3, i5, i7 with varying amounts of RAM and learned a lot from that. In 2021, my first M1 mini, in 2022 a mini M2. All these, I owned for roughly a year, and sold them with a loss of 10-20% of the money. So no regrets.
I read about the new M3s and how people expected the next mini w/M3 would not be a very big leap in number of cores and power. I was so happy with my M2 mini 16/256 that I went all-in and invested in a M2 Pro with more cores, memory, ports ++. I'm expecting it to last me a few years, if not out-live me. 😱
And should I be lucky to still be alive, it's such a good configuration of a mac, that I'm sure I'd get half of my money back if I sell it five years from now.