About all you can do is purchase a recently-released model. Beyond that, it's a roll of the dice. Some Macs end up being supported for longer than others. For example, the the high-end 2018 Intel Mini's have had an unusually long lifespan because there was a long delay before it was replaced with an Apple Silicon mini. There would have been no way of know this back in 2018 however.
What you need to understand is Apple's policy on "vintage" and "obsolete" devices. They support products for 5 to 7 years after they are discontinued. This confuses some people, because it doesn't matter when the computer was released, only when it was discontinued. This often creates support disparities between models that were released at the same time.
Learn about your options for getting service and parts for Apple devices that are past their warranty period.
support.apple.com
This policy is actually about hardware support however (when they will no longer fix a broken computer) and not when they stop supporting it with operating system updates. With one of these "obsolete" Macs, there is generally a period where they will no longer support new versions of the operating system but can still run an operating system that is supported with security updates.
After an operating system stops getting security updates, there could be a risk using it for things like online shopping or banking. But there are some hacks to install new opeating systems on these unsupported Macs. Caveat Emptor...
Now that the transition from Intel to Apple Silicon is complete, my gut feeling is that your expectation of a 10 year lifespan might not be realistic. Not unreasonable to assume that the Mac will still function that long, but it may not be able to run a supported operating system.