Tragically things like Dementia and Alzheimers can do this. Also numerous mental conditions e.g. depression, stress, etc.
I knew one guy that got a degree in Comp Sci and in his first job began getting severe debilitating headaches. He was diagnosed with a visual problem and was told to stop using screens in his day to day job. He quit a promising career as a software engineer and went and joined his dad's gardening business.
Lots of options actually. If you're healthy, able to concentrate on things for a long time and your brain is sharp then count your blessings.
I once (for only a few weeks, but it felt much longer) had to use medication that made my brain feel like mush, comprehension capabilities were a fraction of normal. Very humbling experience, scared to death of losing my faculties and ending up in that fog for some reason that can't be cured so easily.
Pretty much any serious illness can do this. I've dealing with the effects of an autoimmune disease. Other than my slowly worsening condition, I have sat in meetings wondering...how long can I live a normal life...how will I take care of my family if I'm not around... That pesky software bug I'm asked about seems so trivial compared to the health problems I'm dealing with.
Speaking from personal experience, something as simple as a concussion can create such symptoms. For that reason, I find it very easy to believe any illness which could impact your brain physically (such as with fevers or inflammation) could have strong negative impacts on your mental capabilities.
ADHD can cause similar symptoms and more and more people have it. It's something very unpopular to diagnose in adults because many psychiatrists are convinced that it's just a childhood illness.
Many Software Engineers reach for Adderall or Ritalin to help them with this.
I knew one guy that got a degree in Comp Sci and in his first job began getting severe debilitating headaches. He was diagnosed with a visual problem and was told to stop using screens in his day to day job. He quit a promising career as a software engineer and went and joined his dad's gardening business.