People tend to find it difficult to focus as their mind drift away to other places or negative thoughts.
Lack of sleep tends to affect your mind and its ability to function properly as well as the ability to focus on tasks at hand.
Doing too many tasks at once also affects one's mind because the mental energy gets divided and find it difficult to focus on one task at hand. It is better to work with a planner, especially when it comes to dealing with tasks.
Experiencing too many distractions also affects your ability to focus. Find a suitable environment to do your task.
If you suffer from mental health issues such as fear, depression, spontaneous mood changes, and negative emotions, then it can affect your work. Find suitable therapy to deal with the same.