Well, it sounds like you had a panic attack in the open water.
How do you fix that? I can only tell you what I think will work... although, I have to say that none of it has worked for my boyfriend... but it might work for you:
1) Swim in open water more. Get in practice before race day.
2) Talk yourself through the swim. Tell your body to do what it has done in the pool. Stroke-stroke-breathe. Remind yourself that you are a swimmer and you can do this.
That's all I got... anyone got anything else?
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather, to skid in broadside thoroughly used-up, totally worn out, and loudly proclaiming: WOW WHAT A RIDE!!!!"