I have read about people who work hard to make a sum of money, they put all of their focus and concentration into it, and they learn to think positively about it in a way that attracts the right circumstances and opportunities. And at some point, they make their goal and they spend several blissful evenings rolling around in piles of money. But then, they have a sneaking fear ... what if it gets taken away? What if I lose it all? And they find themselves having this fear underneath their enjoyment of their Benjamins, and guess what? At some point, the scale tips and they lose their fortune, needing to start all over again.
Perhaps there is something similar when it comes to learning a piece and then performing (or practicing performing)?
I think though, that with Bach in particular, it is easy to think very linearly (and very kinesthetically - to the point of that taking over) and if that linear train hits a little pebble on the tracks, instead of skipping along, the train goes off the track and the whole ride is suddenly completely over. With any piece it's important to have a huge picture of the work, a detailed picture of the work, and anything and everything in between, but especially with Bach.
Could you plot out a chart of only the larger form of the entire piece? I mean in a way that you can mentally grasp the entire work all at once, as though you could hang that as a picture on your wall (never mind whether it's an interesting picture or not).
Build a backup plan. Don't accept a sense of doom and limitation about if something doesn't go as it should. Instead, practice other options, like improvisation, or skipping ahead to a memory post.