You cannot upgrade the RAM later. If you think you might need 24GB in two years, it is better to buy it now.
The Apple 24-inch iMac (M4 8-core CPU/GPU) is the best starting point. Even for basic tasks like web browsing and streaming, experts at CNET and Hoxton Macs recommend sticking with at least 16GB of unified memory to keep the system smooth for years to come. which apple imac should i buy
Be aware that the absolute base model sometimes has fewer ports (2 vs 4 Thunderbolt ports). You cannot upgrade the RAM later