How many times has this happened to you? You leave work, decide that you need to get groceries on the way home, take a cellphone call and forget all about your plan. Next thing you know, you’ve driven home and forgotten all about the groceries.

Or this. You decide, perhaps circa Jan. 1, that it’s time to lose weight; you need to eat less, eat better and exercise more. But by the first of May, your New Year’s resolutions are a distant memory.

Human beings are, to put it gently, in a unique position in the animal world. We’re the only species smart enough to plan systematically for the future -- yet we remain dumb enough to ditch even our most carefully made plans in favor of short-term gratification. (“Did I say I was on a diet? Mmm, but three-layer chocolate mousse is my favorite. Maybe I’ll start my diet tomorrow.”)

In a wonderful study conducted at Stanford University in the late 1960s, psychologist Walter Mischel offered preschoolers a choice: a marshmallow now, or two marshmallows if they could wait until he returned. And then, cruelly, he left them alone with nothing more than themselves, the single marshmallow, a hidden camera and no indication of when he would return.

A few of the kids ate the oh-so-tempting marshmallow the minute he left the room. But most kids wanted the bigger bonus and endeavored to wait. So they tried. Hard. But with nothing else to do in the room, the torture was visible. The kids did just about anything they could to distract themselves from the tempting marshmallow that stood before them. They talked to themselves, bounced up and down, covered their eyes, sat on their hands -- strategies that more than a few adults might on occasion profitably adopt. Even so, for about half the kids, the 15 to 20 minutes until Mischel returned was just too long to wait.

Toddlers, of course, aren’t the only humans who melt in the face of temptation. Teenagers often drive at speeds that would be unsafe even on an autobahn, and people of all ages have been known to engage in unprotected sex with strangers, even when they are perfectly aware of the risks. (To say nothing of the daily uncontrollable choices of alcoholics, drug addicts and compulsive gamblers.)

What gives? Why are we as a species so often so desperately poor at achieving our goals? If we are, as the selfish-gene theory would have it, organisms that exist only to serve the interests of our genes, why do we waste so much of our time doing things that are not, in any obvious way, remotely in the interest of our genes? How can one explain, for example, why a busy undergraduate would spend four weeks playing “Halo 3" rather than studying for his exams?

The selfish-gene theory doesn’t, in itself, answer these questions, but there is another facet of evolution that can: The fact that evolution is entirely blind, unable to look forward, backward or to the side. As Charles Darwin observed, evolution invariably proceeds through a process called “descent with modification.” In lay language, this means that Mother Nature never starts from scratch, no matter how useful an overhaul might be. Everything that evolves necessarily builds on that which came before. Our arms, to take one simple example, are adaptations of the front legs of our primate ancestors.

In practical terms, that means that evolution’s products aren’t always particularly sound. Truly dismal solutions are quickly weeded out; if someone has a genetic condition that brings them into the world without a functioning heart, they don’t live long enough to reproduce. But merely adequate solutions (what engineers call “kluges”) -- like the awkward, injury-prone human spine, good enough but far from perfect -- can stick around indefinitely if better solutions are too far away on the evolutionary landscape.

In the mental machinery that governs our everyday decisions, kluges abound. Take, for example, the scenario described in the beginning of the essay -- the fellow who forgets his errand on the way home. His problem is clearly not in finding his way to the grocery store -- it’s in remembering to go in the first place.

The problem is that evolution failed to realize that remembering goals is not like recognizing objects. When your brain sees a lion, the thing to do is to decide, lickety-split, to get out of the way. Run first; ask questions later. We’re programmed for just that kind of split-second decision; just about every creature on the planet is built such that it can identify things like predators and prey very rapidly. We’re not programmed to remember precise episodes from the past. Why not? Because remembering the exact date on which you last saw a lion is not particularly helpful when you’re trying to get out of the way.

Alas, evolution didn’t have the foresight to realize that different kinds of tasks require different kinds of memory, and it used the same basic sort of memory for everything, not just for remembering what lions and tigers look like (in which general tendencies suffice) but also for cases -- like tracking our goals -- where a bit more precision would have been helpful. As a result, trying to remember what to do next can be a little like trying to remember what you had for breakfast yesterday: There are too many breakfasts and too many yesterdays for our biological memories to keep track of.

The same thing can happen with our goals. When you sit in your car late in the day and ask yourself, “What am I supposed to do next?” and all of a sudden the cellphone rings, your brain can easily lose track of which “next step” is the right one. Instead of zeroing in on the specific memory it needs, it may well settle for remembering whatever you’ve done in the car most often -- and that’s drive home. Voila, autopilot.

Our attempts to pursue our goals are often thwarted by the fact that evolution has built our most sophisticated technologies on top of older technologies -- without working out how to integrate the two. We can plan in advance, using our modern deliberative reasoning systems, but our ancestral reflexive mechanisms, which evolved first, still basically control the steering wheel. When the chips are down, it’s those mechanisms that our brains turn to, and that means that our brains frequently wind up relying on machinery that is all about acting first and asking questions later, squandering some of the efforts of our deliberative system.

No sensible engineer would have designed things this way. Why design fancy machinery for making long-term goals if you’re not going to use it? Yet the brain is structured such that the more tired, stressed or distracted we are, the less likely we are to use our forebrains and the more likely to lean back on the time-tested but shortsighted machinery we’ve inherited from our ancestors.

Still, all is not lost. Even though our short-term desires are pretty good at grabbing the steering wheel of our consciousness, our more recently evolved deliberate minds are powerful enough to regain at least some measure of control.

Consider, for example, the difficulty that most people having in sticking to abstract goals like “I intend to lose weight” or “I plan to finish this article before the deadline.” Nice thoughts, but not formulated in terms that your ancestral, reflexive brain might understand. The work-around? Translate those abstract goals into a form your ancestral systems -- which traffic largely in dumb reflexes -- can understand: if-then. If you find yourself in a particular situation, then take a specific action: “If I see French fries, then I will avoid them.” As Peter Gollwitzer, my colleague in New York University’s department of psychology, has shown, even simple changes like these can markedly increase the chances of success.

Our conscious, deliberate systems will never have total control, and our memories will never be perfect, but as they say in Alcoholics Anonymous, recognition is the first step. If we come to recognize our limitations, and how they evolved, we just might be able to outwit our inner kluge.

Gary Marcus, a professor of psychology at New York University, is the author, most recently, of “Kluge: The Haphazard Construction of the Human Mind.”