Unfortunately, you cannot upgrade that 21.5" iMac to "the latest version".
The screen size, and the fact that it is running OS X 10.9.5 (Mavericks) now, tell us that it must have a hardware model year between Late 2009 and Mid 2014 (inclusive).
That means that the highest version of macOS that it can run is
- High Sierra (2009 – 2011 models),
- Catalina (2012 – 2013 models), or
- Big Sur (2014 model)
Even Big Sur is five major versions behind macOS 26 (Tahoe).
You can find out the hardware model year by selecting About This Mac from the Apple () menu.
Updating from Mavericks to a higher version of macOS may involve extra steps. Mavericks is probably too old to even handle the modern https security protocols needed to visit
How to download and install macOS - Apple Support
You may need to use a modern Mac or PC to download the .DMG file containing the Sierra installer onto a flash drive, for transfer to the old Mac. (This will NOT produce a bootable installer. It is just a way of getting the file downloaded and over to the old Mac. You'll need a running copy of macOS on the old Mac to open and use the .DMG file, so DON'T erase your Mavericks installation!)
Once you successfully install Sierra, its versions of Safari and the App Store will hopefully be recent enough to let you access the Support article directly from the old Mac, and use the appropriate App Store link to upgrade your Mac to whatever version of macOS it supports.