If you're trying to do thing A but your brain can't stop thinking about thing B, take out a notebook and write down all your current thoughts on thing B. Trust yourself that when you get back to it, you will be right where you left off. Then do thing A.
For example, trying to work on a paper but you can't stop thinking about the season finale of your favorite show you just watched.