Safari is updated when you upgrade the operating system on your iMac.
The model year of an iMac is available at Apple menu > About This Mac.
An early 2009 iMac can be upgraded to El Capitan 10.11.6 but no later version. See: https://support.apple.com/en-us/HT211683
A late 2009 through mid 2011 iMac can be upgraded to High Sierra 10.13.6 but no later version. See: https://support.apple.com/en-us/HT211683
A late 2012 through late 2013 iMac can be upgraded to Catalina 10.15.7 but no later. See: https://support.apple.com/en-us/HT211683
A mid 2014 and late 2014 can be upgraded to the latest version of Big Sur macOS 11 but no later. See: https://support.apple.com/en-us/HT211683
A late 2015 or later can be upgraded to the current version of Monterey macOS 12. See: https://support.apple.com/en-us/HT212735