For that choice personally, I would go with the M4 Mac. Macs are very efficient with memory management, and if you know for certain you'll be working with apps/files that typically require more memory (e.g. video editing, high-end gaming), 24 vs. 16 memory of RAM will not make enough of a difference and you should be looking at a MacBook Pro (with at least the M4 Pro chip and 48 GB of memory).
Another consideration if you tend to keep a Mac for a while is that at some point, Apple will stop supporting older hardware. 5 years from when it was last sold (by Apple directly), Apple considers a product 'vintage' and they may not service it (it depends on availability of parts). 7 years from when it was last sold, Apple considers a product 'obsolete' and they will not service it at all. Since the M3 MBAir was officially discontinued in March of this year, getting the M4 will give you more time to have your Mac fixed if something goes wrong. Same story for software support, most likely the M3 will stop running new versions of macOS a year before the M4.