You can get the 24" M3 iMac with 8, 16, or 24 GB of RAM.
Although Photoshop, Lightroom, and Lightroom Classic can run in 8 GB of RAM, Adobe recommends 16 GB of RAM – or more – for each of these programs. I would advise getting no less than 16 GB of RAM. Consider getting more if you are going to work with huge (100 megapixel) photos, work with a lot of layers, or large panoramas.
You can get the M2 Pro Mac mini with 16 or 32 GB of RAM, and the M2 Max Mac Studio with 32, 64, or 96 GB of it. It seems unlikely that you would need 96 GB of RAM (you might not even be able to take advantage of 64 GB), but you can get that machine with that much.
Although the M3 is a newer-generation chip, the M2 Pro and M2 Max are higher up in their lines, and thus are likely to have stronger multi-core CPU performance, and GPU performance, by virtue of having more cores.
https://www.hoxtonmacs.co.uk/blogs/news/apple-m2-vs-m3-chip-comparison