It's the magic sauce of software and hardware integration. Also the hardware is just bonkers.
I thought for the longest time that the whole trackpad clicked when you pressed down on it. Nope, it's just a taptic engine hidden in there. If you turn off the haptic click, it's just a flat pane of glass.
Then there's the palm detection, I've used Macbooks for almost a decade for work and I can't remember when was the last time I had a misclick on the trackpad when I was typing. I did have a ton of issues with Dell and Lenovo laptops. On Lenovos I just used the red nub and disabled the touchpad from BIOS =)
Other vendors vary dramatically, even between models.