Mac Mini allows you the option to pick the size and style of monitor that best works for you. Unless you're going significantly high end, Mini plus monitor (+ keyboard + camera) is less than cost of iMac. Also, should something go wrong with device, you're only taking in / sending away a little 8 x 8 box, not something much bigger.
M2 Mini now over a year old (released in Jan 2023), so if they keep up with that release schedule, maybe a M4 come next year? That said, deals can often be found found online now for M2, and includes Apple's own Certified Refurb site. Products there all individually checked (so arguably, better than factory new), are eligible for AppleCare and shipped free.
(PS - If you go the Mini route, you may wish to have a wired keyboard and mouse to hand for initial setup - reports of mixed success with bluetooth devices being seen during setup, when you need to input info.)