From what I've observed, moderately priced bikes tend to be more sane in terms of adhering to mainstream component standards. For instance I bought a fairly generic "sporty looking hybrid" in 2006 for which I've had no problems sourcing parts -- although very few parts have been needed. Outside of competitive or off road use, good bike parts are actually quite reliable and last a long time.
Trek, Giant, Specialized, Raleigh, Fuji... Some of these have become "just a brand name" under new ownership.
I also have a bike that I threw together from 40 year old parts, and can still get any replacement that I need from Amazon or eBay. I suspect demand from overseas may be keeping some parts for older bikes available.
I think you can contribute a lot to the lifespan of a bike by learning to do a bit of your own maintenance, so you can spot minor issues before they turn into component failures.
At least some of the big name bike brands have lifetime warranties on the frames. Everything else can be considered a consumable item. Not because it's designed poorly but because you'd rather your bike weigh 10kg less than increase the lifespan of some parts from 5 to 50 years.
Proper maintenance and quality parts last 50 years (my commuter bike and most of its components are 40 years old. Tires, chains, cogs, brakepads, saddle and bartape are the exception).
Anything but the cheapest of components would last years with proper maintenance (which has cost in service charges: good bike mechanics don't come cheap)
If you ride your bike a lot, and some point the bearing races in the hubs will wear out and you'll need new hubs, same for the bottom bracket, the rims will either get ground down by the brakes or get a dent that requires them to be replaced, fenders will get bent and / or rust off, screws corrode, brake / shifter cables need to be replaced every few years...
Bikes that get ridden a lot are like the ship of Theseus...
That specific one is 40 years old, but I only owned it for the last four. All my bikes were bought used: like cars, once you roll them out the shop's door, you loose a significant amount of the purchase price.
When I worked at my local bike shop we promoted Seven Cycles as a custom alternative to the retail stuff we were pushing. I know we had several riders who had their bikes well over 15+ years. The titanium frameset lasted easily that long, along with some wheel sets, brake upgrades and component upgrades along the way - but overall the frame and fork seemed to really have some longevity.
They aren't cheap but the investment I've been told is worth it:
Probably the best and simplest indicator is to look for 8 or 9 speed on the back wheel, or a premium rear gearbox like a rohloff, or either a 3 or 5 speed sun gearbox like a sturmey archer or shimano 3 speed.
Brands will vary both in servicability between models and which hrands are available.
Avoid any integrated electric parts that the frame is builtaround (but a bolt on motor and battery is fine whether the motor is fitted to the wheel or pedals).
usually if the bike is not a triathlon bike and the seat post is cylindrical, everything else on the bike beside frame are replaceable with plenty options. And most of the lower end of each brands filled with these
Ask your local, independent bike shop for specific recommendations if you need those. Bikes components are highly standardized.