There ought to be a recall with this issue. I learned about it the hard way, buying a used HTC 10. Cosmetically in great shape. I thought I was all set... and then... this very same battery problem. At about 25% or less, phone abruptly shuts down and then goes into a repeating boot loop. Spent a whole weekend troubleshooting it -- wearing the battery down from 100%, slow charging, battery tests. The HTC Battery test showed the phone at 70% after 1 hour, which is TERRIBLE. My 4 year old One M8 goes down to 90% in 1 hour.
It sounds like it's some kind of battery fault. For a 2 year old phone, this should not be happening. I'm really shocked HTC allowed this to go on with no recall.