You know, I believe there are many reasons why it happens, it's difficult to point all of them, and I don't think I know all of them, but here are some I can think of now:
1. When speaking a foreign language, we feel vulnerable, especially when we don't have a complete domain of it, or are not used to it.
2. Since communication is something so primary, we're afraid of failing it, we feel like it would sound ridiculous if we couldn't speak perfectly, and this fear dominates us, we're afraid of looking stupid in front of others.
3. Learning a new language is something challenging, and it takes a lot of dedication. Possibly, people imagine how frustrating it would be if they realized that they're "not good enough" or "they can't communicate", despite how much they have worked on it.
4. People are afraid of bothering others (especially native speakers) if they can't pass their message across with 100% of accuracy and clarity.
Obviously, those are all things that come to our mind BEFORE we speak a foreign language, therefore, one can control this situation by convincing himself/herself that those feelings are a result of their imagination, they're not real (they haven't even happened yet!), and there's nothing wrong about trying to learn a new language, it's actually the opposite: it's something worthy of pride!
I believe Ester has hit the nail on the head.
I get scared when I speak Chinese, but I know I shouldn't. I get scared because when I speak English I sound like the educated adult that I am. When I speak Chinese, on the other hand, I haven't a hope in hell of sounding like the educated adult that I am, I will sound like a confused 5 year old that makes grammar and pronunciation mistakes all over the place. I don't want to sound like a silly child, and that holds me back sometimes. However, as Ester said, communication is the most important thing. So long as I am communicating with others then I ought to be happy with myself. This is one of the main reasons children learn better than adults - children aren't afriad to sound like children because they are children.
I participated in a MOOC a little while ago that paired up Spanish speakers with English speakers randomly so that they could go through exercises together online. During the first session, I had to laugh when I saw in big letters "Don't close the window!" on the webpage as the session started. Apparently they were having a big problem with the participants panicking as the exchange was about to start and running away.
I don't feel afraid too often. Mainly because I am not afraid of being embarrassed. The thought of not sounding cool does not bother me because I <em>know </em>that I don't sound cool. I never have sounded cool so I got used to that reality a long time ago haha.
Lack of confidence and enviroment is not good to speak.