One thing to consider is that the RAM on an M2 system is not upgradable, because it's part of the SoC package. However, Apple's design does well in terms of memory bandwidth and efficiency of the unified memory architecture.
(Note when I last made a comment like this on HN I was "corrected" by being told that the ram is "nothing special" and "just LPDDR2." Which seems to miss the interesting bits of co-packaging, 100 GB/s memory bandwidth, and unified CPU and GPU memory.)
Also Apple laptop SSDs are soldered on the motherboard (though 5-6 GB/s data rate on the MacBook Pro 16 seems decent.)
For Apple laptops, I would probably try to get the most RAM and SSD that I could afford, especially if you want to use it for several years (my MBP from 2016 is still going although it was abandoned by the current macOS Ventura - a schedule probably accelerated by Apple's ARM transition.)
[dead]
The one thing that might prevent you from using it for 10 years is the OS, specifically its lack of support for your device beyond a certain point.
Btw if you'd like to spend less money, you could opt for the M2 Macbook Air which should perform similarly for most workloads (exceptions being video editing and AI/ML). That's what I have and I can highly recommend it