Do not forget that every OS update needs to go through your carrier before arriving to you, and they might not care to do the vetting work, barring you from getting the updates.
On the other hand, an iPhone is usable for 9-10 years with updates and EOL support. You'll change your battery once in mid-life if you look after your device well.
My iPhone 6 was released on September 19, 2014 and it received its last OS update on September 17, 2018 with iOS 12 so it received only 4 OS updates updates. It continued to receive minor security updates until June, 2021 so about 6 1/2 years. Although, the security updates it received after 5 1/2 years were minor and not comparable to the full updates non EOL devices received.
On the other hand, an iPhone is usable for 9-10 years with updates and EOL support. You'll change your battery once in mid-life if you look after your device well.