You haven't said which 2018 MacBook Pro, and which 2024 MacBook Air, you were thinking about.
There were two 2018 MacBook Pros, both Intel models
- MacBook Pro (13-inch, 2018, Four Thunderbolt 3 Ports)
- MacBook Pro (15-inch, 2018)
These MacBook Pros can run Sonoma, and will be able to run Sequoia – but it is quite possible that they will never receive any new versions of macOS after that.
They have the infamous "butterfly keyboard" design first introduced on the 12" Retina MacBook. This key design makes it more likely that dirt will get trapped in the key mechanisms in a way that you cannot remove – short of a very expensive repair. Apple had a keyboard service program to fix or replace faulty "butterfly" keyboards – but that program has expired, so If your keyboard went bad you would be on your own.
Those models are also old enough that they're getting close to the point where Apple might not offer repair parts, or repair service, with the exception of battery replacement service.