How does being afraid or nervous affect mental performance?
I will try using logic, but that might only just get you on a lead:


Concentration means being focused on a specific task.
Consciously, you want to focus on a specific task, but there are other process that may want to claim ressources and that you cannot repress. 
Anxiety, but also fear or worriness are symptoms that basically translate an unconscious (or conscious) proccess that requires your attention. 
Therefore, two concurrent psychological process require focus from your conscious mind. Ergo, you cannot concentrate on either on them. Usually, the emotional part will win since it involves brain structure (such as the amygdala) that are specialized in shunting more evolved brain structures. That is when you are afraid of something, it is very hard to repress that feeling with logical thinking.
In psychoanalysis, Freud introduced something called as "The pleasure principle" (I hope that's a good translation). This principle is one of the few basic principles that rule human behavior. Now, anxiety is an indicator of displeasure. Your mind will try its best to settle that issue before settling anything else. That is why usually you cannot isolate anxiety.


Here's an example:
You hate spiders. You need to measure the surface of an old mannor. You've seen some spider webs. Odds are you will have much trouble to concentrate on measuring any room's surface, because one task your brain will perform for you is checking in every corner whether a spider can be seen, so you'll be able to identify a potential threath as soon as possible and react appropriatly (usually, get the hell out of there if you're really affraid of spiders.

Here's another example that doesn't use fear:
Your girlfriend texted you before an exam, and she said "We need to talk". Since you are emotionnaly bound to your girlfriend, you might get anxious: what does she want to talk about ? Your mind will begin scanning for every possibility, emphasizing on the worse ones (the ones that will disturb the "Pleasure principle" the most for instance). Now that you identified that she might break up with you, this thought will just keep popping up, even if you manage to think for a minute about the exam you should be thinking about right now.

Fact is this is a matter of autoconservation for your psychee. A breakup will certainly harm you more than a failed exam. Your brain is very smart about processing important stuff before, and any attempt from your conscious mind to shunt this will most probably fail.

By the way, there is a psychology stackoverflow. I guess you should have posted this question there.

Hope this helped !