When I cannot concentrate on something, I usually change my occupation (I go for a walk, for example). And if this happens systematically, then there is a problem in the work of the brain, you need a healthier diet and lifestyle in general.
Not all of us can concentrate for too long and in between you just need to take a small break so that when are you doing something there is a complete focus and attention on it. This just helps you to concentrate 100% during that time and also in between breaks helps you refresh and have some sort of relax time for yourself.