Most devices continue to be supported for a few years, but true, some makers don't.
I know that, for me at least, the ability and willingness to support for at least a 2-3 year window has become a significant factor. I'm not sure you can expect support for too much longer...the hardware environment with phones evolves so fast. If you ask for 5 years...that would be Froyo. Android 2.2. (Wiki says 2.3 was released in December 2010.) Obviously, the changes between then and now have been enormous, and it's quite likely that a security patch for 5.1 would have to be completely redeveloped to patch 2.2. If it even could be.
I wonder how much the handset makers really foresaw the need for mid- to long-term...call it 2 years for mid-term, 4 for long term...support. When did the security issues really start to surface...a year, maybe 18 months ago? What I think is, we're in the paradigm shift now...from lifestyle adjunct/semi-toy device, to an essential tool and a core part of more peoples' lives, and with a need for security that is equal to the need of a full-blown PC. Or maybe it's just easier to say...they might be small, but modern phones ARE full-blown computers.
Also: we, the users, have encouraged this. A big chunk of the user market buys the big, long-term, EXPENSIVE plans that say, yeah, UPGRADE. We're overcharging you for the plan by SUCH a large amount that we can afford it. This market segment never kept a phone for more than 2 years...so how can you blame the handset makers for planning on longer-term support? As long as the users continue to chase the rainbow of the IDEAL PHONE, obsolescence is inherent.