And that can be as good for the mind as running is for the body. “Doing something good, we know from research, is helpful for self-esteem,” said Dr. Brown, who is also a co-author of the book “The Runner’s Brain.” “So to me it’s a win-win. A lot of people are probably doing it for themselves and to support the charity.”

A 2010 study by Karin Ann Jeffery, a master’s degree candidate at San Jose State University, found that participants in the same charity marathon training program became more deeply connected with the cause over the course of the program, which in turn became an increasingly powerful factor in their motivation to train, although not the only one. Improved fitness and support from within the training group were also cited as powerful incentives to stick with the program.

Clearly, running for a cause — no matter how connected one might have felt to it at first — can be a powerful motivating force. According to the 2016 edition of an annual survey of runners by Running U.S.A., a nonprofit organization that tracks trends in the sport, four out of 10 say they are influenced to race by a charitable cause or affiliation.

That number has stayed the same even as overall running participation, in both marathons and shorter distances, has declined in the last few years, according to Running U.S.A. Moreover, fund-raising for running events on the online fund-raising site CrowdRise is growing by 18 percent annually on average, a CrowdRise representative said, suggesting that even as the total number of runners had declined, their fund-raising impact had increased.

While many run for large cause-based teams, such as the Leukemia & Lymphoma Society’s Team in Training program, others pursue solo fund-raising efforts.

Jay Asparro, 37, of Plainview, N.Y., ran in last year’s marathon as a member of Team for Kids. Like Ms. Quan, he admits his initial motivation was simply to secure a spot in the race. Next Sunday, however, he is planning to finish a three-day, 90-mile ultramarathon across part of Long Island to raise money for the Long Island Alzheimer’s Foundation and to increase awareness about the toll the disease takes on loved ones. His 91-year-old grandmother, Ann Asparro, has Alzheimer’s disease, and Mr. Asparro said he had seen the strain that caring for her had placed on his parents.

“I’m doing it for my family,” he said, “and for other families suffering through this.” By the middle of October, he had raised $7,758.