This statement presupposes that there is a reason.
Many people simply act completely irrationally, so the only "reason" for their actions that one can come up with is the overly reductive "well, their neurons fired in such a way that resulted in them doing <whatever>".
I suspect avoiding generalities would assist discourse, so here's a concrete example to analyze: consider a senior (maybe even staff level) software developer, trying to write a loop. He writes a bunch of code, runs it (via tests, or executing the software itself), and finds that it doesn't work. So now he he changes the "<" to "<=". Still doesn't work. Now he changes that to ">". Still doesn't work. Now he changes that to ">=". Still doesn't work. Now he thinks "prime numbers are sometimes important, hm...", so he rounds the end of the range to the nearest prime number. Still doesn't work. Now he increments by two, instead of one. Still doesn't work. On a whim, now he changes the numeric type from an integer to a float, though he (of course) couldn't explain why that would change anything (all other things being equal in this scenario, it wouldn't). It still doesn't work. Etc, etc, etc. This sort of pattern continues for the next couple hours until the code happens to work for the scenarios tested (though is still incorrect and will eventually fail in production).
What is the "reason" for this behavior? Or, more importantly, why would someone regularly engage in such behavior? Why, as opposed to reasoning about the code, instead spend hours being superstitious, cargo culting, guess-and-checking, etc? Why never once consider pre-/post-conditions, loop invariants, sketch out a small informal proof by induction, etc?
Yes, some instances of bad decision making are due to unfortunate circumstances (stress, mental health, etc). But there are times where people simply demonstrate that they are, putting it kindly, not competent. That doesn't make them any less deserving of love and care, but they are still (with no negative sentiment or judgement intended) incompetent.