I learned to play chess when I was twelve. It really taught me to think ahead. My teacher cut me zero slack and just slaughtered me mercilessly over and over again. Losing at chess repeatedly because you don’t stop to think a move or so ahead is just the right amount of painful to drill the practice into your head. I now cannot fathom failing to think ahead.
Also, drop the caffeine. It leads to scattered thinking.
Slow down, learn to meditate and cut yourself a bit of slack. Being angry with yourself just makes it worse.
If there’s something you can’t afford to forget or get wrong leave yourself a note or a checklist. I use checklists every day. (Because I think ahead but want to make sure I don’t forget)