I also have this problem. Here are some tips I've found useful.
-- When possible, do things that you're passionate about. Develop your passions and try to work within those constraints.
-- Have a single monitor
-- Create a TODO list. Also start the day or working session with planning.
-- When tackling new problems, try to do the easiest tasks first to build momentum, before tackling harder tasks
-- Break down tasks into the smallest components and do them one at a time
-- Give yourself a reward for doing a small section of tasks (ie. watch a YT video)
-- Develop your self confidence and create a strong passion for competition, that's driven me past a lot of my attention problems