There are a couple of ways to interpret the series of events and how each mutant has lost their powers.
1. They're both getting old.
At the time of Logan, Xavier is about 97 years old. Logan's physical body is reaching about 150 years old (although depending on the timeline shenanigans he could mentally be a lot older). Logan hasn't been kind to his body, relying on it's healing ability heavily throughout his life. We don't know the science, but it could easily be that since he's gotten older his powers have weakened, either due to old age or the extensive use of his power. Add on top of that the adamantium in his body poisoning him, and you've got a Wolverine that can't heal as well.
Charles, at his age, is suffering from seizures, and seems to be suffering from Alzheimer's and dementia as well. At the time of the movie the mix of old age and mutant powers is unknown, but with Charles having a psychic ability it wouldn't be surprising if the two are hand in hand, IE his ability causing his illness
2. They're slowly being killed by the chemicals in the food
Both Charles and Logan, along with their friend, are relatively alone in the world. It has been years since a new mutant has born, and previous events have killed off most other mutants though either mutant hunting or mass die-off events, such as Charles' seizure accident.
It was stated later in the movie that naturally born mutants stopped because of a chemical introduced into the food supply. Since this chemical somehow suppresses the mutant gene, it wouldn't be surprising for it to have an adverse, if not long term, effect on those still living. We don't know the chemical or how it works, or what it's long term effect is on those that are mutants that are living.