This is a pretty good example of why asking people to write code in an interview is a pretty poor way to measure their fitness for the job...
The brain works this way, which is why you feel sleepy when you go to bed (unless you spend a lot of time in bed not sleeping). It's a type of compartmentalization, well known in psychology.
If you're a good coder/public speaker, you have to practice white board coding if you're looking for a job.
I've never worked at an organization where folks didn't work through ideas together at a whiteboard. Some of said "work through" involves code snippets.
So, while coding on a whiteboard may not be necessary/useful, communicating about code on a whiteboard is extremely important.