My problem with these is that they are generally written by the developer who wrote the function.
So devs code the happy path in their function, and test the happy path in their unit test.
Yes, in fact, 2+2 is in fact 4.
But, do they test add(2,-2) or add(-2,-2) or add(null,2) or add (0,null) .. etc.
Whatever cases they forgot exist and never coded for, never get tested for either. If this is not caught in the initial commit by another dev, then it makes it through to prod happily despite having "unit tests".
This is why I think tests where the application is forced to interact with real world data are better because if your app will be broken by negative/0/null, and that state exists in the real world data, it will break in testing.
Of course this is all a long dissertation on how to code&test the addition of 2 integers. One of the simplest possible functions, now do this on more complex software.
The unit test I think biases later developers to believe the original developer actually coded the software correctly, when to me, in a large number of cases.. it was wrong to begin with, but uncaught.