iPhones already don't get full updates. They get progressively trimmed updates as time goes on. Stock android does a similar thing. If you get a Pixel, you get 2 years of OS updates (my Pixel from 2016 is running the latest Android), at least 3 years of security updates, and many software updates in the meantime (most of Android's functionality can be upgraded without an OS update).
FWIW, phones aren't designed to last 5 years. The batteries aren't, the screens aren't, the casing isn't, and the hardware generally doesn't (newer software = more demanding).
That said, if you do require to use the same device for five years, and need the latest software on it, than Apple is probably your only option.