Not sure if I should go for the iMac, mac mini, studio or pro.
Well, that covers a range from $600 to $7000, of which the $600 version would probably get the job done... so it really comes down to how much you want to spend for "bragging rights". So, let's go through them:
M4 Mini - Would most likely get the job done (apart from the silly 256GB SSD for which you'll probably just need to pay the Apple upgrade tax if you're planning on installing pro apps or using VMs). Might not be night-and-day better than your 2020 iMac (depends which model) depending on the workload.
M4 iMac - Comes down to whether you like all-in-ones (I don't) and can live with a 24" screen after 27" (I'd prefer a pair of matching 27" 4ks) - display should more than match your iMac in sharpness and quality, but... 24"... and you're about to experience the pain of having what is still a top-notch display that can only be used with the outdated built-in computer...
M4 Pro Mini - Probably the best bangs-per-buck at the moment as long as you don't upgrade it to > $2000 at which point you might be better off waiting for the M4 Max Studio which is
hopefully coming next year (but not certain).
M2 Max Studio - still a good & very capable system but really not attractive now with the M4 Pro mini is 2 processor generations ahead. I'd prefer the design and build over the (IMHO pointlessly small) Mini, but wouldn't buy one right now unless you got a good refurb deal. M4s have better single core speed (which is still key for many apps), a better balance between CPU and GPU and things like hardware ray tracing and significantly improved neural engines (the last two might not affect you).
M2 Ultra Studio - will still clean up on multicore CPU and GPU benchmarks but unless
your workflow makes use of that level of multithreading and GPU-based processing you might see very little practical benefit. If/when a M4 Max studio appears it will probably offer far better bangs/buck - and if a M4 Ultra appears that will thrash M2 Ultra
Mac Pro - forget it: if you don't already know why you'd need it, you don't need it. It's really a M2 Ultra Studio plus internal high-ish bandwidth PCIe slots for specialist I/O, A/V and super-fast storage cards (not GPUs). Some people evidently need those slots enough to pay $7k for the base model - you don't.
Displays - you've been spoiled by the iMac 5k display, and anything other than a Studio Display is going to feel like a bit of a downgrade. The Samsung S9 5k hasn't been very well received (partly because it's list price is silly, but it's widely discounted) and there's only a couple of currently-vapourware 5k options. Don't get confused by "5k2k" displays which are ultra-wide displays with the same PPI as a 4k UHD (which isn't to say you might not like one). 5k@27"/220ppi is certainly "optimum" for MacOS but... well YMMV, but the "problems" with using 4k UHD displays on Macs are, IMHO, rather overstated, and they're actually a perfectly good compromise considering the price difference.
I'd "think different" with displays - I'm currently using a pair of Huawei Mateview 28" 4x3 format "4k+" displays which are basically like having a 4k 27" display with an extra inch and a bit of screen space grafted on the bottom. Not quite up to the same standard as my old 5k iMac
but perfectly good, and I find the layout & ridiculous screen estate of more
practical use. For development you can have your IDE full-screened on one display and your app and/or reference material on the other.
OK, "ooer! Huawei" and all that - plus I think they're actually discontinued now, but if I were starting over I'd definitely look at these puppies, from a less-contenious manufacturer:
BenQ RD280U promote programming productivity with backlight, Fine-coated panel, and advanced coding modes, delivering crystal-clear fonts for improved code differentiation in both light and dark themes adaptable to diverse development work environments. Accessible at a touch of the dedicated...
www.benq.eu
What can we do to this old intel iMac from 2020?
Right now? Still a pretty capable machine. If you're not sold on the Mac Mini, I'd stick with it and wait for a M4 Max Studio (and maybe more display options) to appear.