I agree @918HCKR that all foods should be rotated. FIFO concept.
That said I do have home canned foods that have kept well for 4 years and, some, longer.
The foods, of course, lose nutritional value and texture. I remove my rings after 24 hours and gently wash the jars in warm soapy water. It's easier to check for a break in the seal without the rings causing a "false seal".
Don't take me wrong please. I think the 18-24 months is a solid recommendation, just not an absolute.
I'll be using some pickled jalapeños in a recipe today that I canned in 2019. The seal was great but the pepper texture is soft. Taste is still awesome
When I help folks get started in canning I always recommend strictly following trusted guidelines, such as Ball's Bluebook and USDA too.
Since I'm gimped up (ankle surgery) I'll be very late getting my garden started this year, but look forward to grabbing some fresh veggies from the local farmer's market and canning them .
Canning links below:
https://www.nifa.usda.gov/about-nifa/blogs/usdas-complete-guide-home-canning
https://nchfp.uga.edu/#gsc.tab=0
https://www.ballmasonjars.com/products/essentials-accessories/accessories/ball®-blue-book®-guide-to-preserving%2C-37th-edition/SAP_1440021411.html