In most cases, they don’t. Mathematicians are way too lazy to waste time or energy memorizing stuff. They learn basic principles and how to apply them. That means that most of the time they know how to figure things out in order to reconstruct theorems and equations and proofs.

Of course, this attitude can sometimes lead to strange behavior. Here is a story from back in the days when I was a practicing mathematician. One of my graduate students came into our weekly meeting and started by writing a theorem on the chalkboard. (Yes, it was a long time ago.) Before he could go any further, I stopped him: “Wait. Why is that true?” He turned slowly, with a puzzled look on his face. “Because you proved it.”

It turned out to be a theorem from one of my published papers. Not only did I not recognize it, my first reaction on seeing it written down was that it must be false. The good news, however, was that once I accepted that it was true, the two if us went on to figure out how to generalize it.