For tech people, OS X is basically a BSD with a pretty UI that comes preinstalled on nice hardware (which is important mainly because corporate IT procurement is only gonna give you a choice between a Mac or a [Dell|HP|Lenovo] business-line machine running Windows (and with corporate policy that prohibits installing Linux). The Mac is a much nicer choice in that situation.
Also remember that, although they’ve backed away from it now, there was a time back in the 2000s when Apple was leaning into the UNIX hackability of the OS – they were coming out with stuff like XServe and Automator and went out of their way to design their machines for toolless upgrades of things like RAM. Some of the popularity of Macs among technical people stems from that era, and memories of it.
iOS, by the way, has always been an entirely different story. Your experience with a cracked iPhone isn’t even slightly representative of the experience using an OS X Mac.