Really great thread, I've learned loads reading the replies.
Like quite a lot of other posters have mentioned, and from my own modest experiences, the maximum time I've had an operable Mac for, from point of purchase, was my very first - a 2002 Power PC Power Mac. Incredibly, my partner ended up using it as muck-around computer to play World of Warcraft on. Amazingly, we retired the old thing in 2010 - so I got a good 8 years of functioning life out of it. Ok, it was only running WoW at around 10fps, but still, it was as solid as a rock. My memory might be faulty, but I can not honestly recall it ever crashing. In terms of its "productive" life (as my main music/work computer), I got around 4.5 or 5 years out of it.
My next Mac, which was a 2006 Polycarb iMac, which ran really well, and it was my main music computer. Unfortunately, it suddenly conked out in 2010 without warning (from my shaky understanding, that first batch of Polycarb iMacs were allegedly prone to overheating problems), so I got about 4 years of life out of it. The Mac I had before the one I've just bought was a Mid 2010 iMac. In 2010, I bought my partner a Mac Mini (with optical drive), and got another iMac for myself (the fat unibody iMac) in the same year. My partner's computer was, in truth, thrashed, as WoW was played to death on it. That lasted until the middle of last year, so that got 5 years of life. The fat Unibody iMac was by far the worst iMac I've ever owned. From the get-go there was just one problem after the other. I'm not sure what caused it, but the drive failed completely in 2014 - meaning that this Mac lasted for under 4 years.
I've just bought a 3.2ghz Core i5 iMac with 16gb of RAM and Fusion Drive (the late 2015 model), and I'm hoping that despite my lack of nous with computers, this will last a bit longer than my most short lived (which as mentioned, lasted under 4 years). My partner also got a new Mac Mini last year, so we'll see how that goes.
So I guess the average for all of the Macs added together is around 5.5 to 6.5 years. I ought to admit a caveat: I'm really, even after fourteen years of Mac ownership, only just beginning to really grasp how to maintain and care for Macs. I'm not proud of this, but just being truthful. I have absolutely no doubt that a computer-savvy person would extend that 5.5-6.5 year average I clocked up by, I would guess, at least a year or maybe two.
In my less optimistic moments, I've fretted that Macs don't feel like they are as well made as they used to be, but I doubt this very much when I reflect on it. I just think I'm rubbish with computer maintenance. I realise now that Macs do need just as much attention as a PC, and that I have to pick up problems before they happen.
Anyway, good luck picking your computer!