Some people are more prone to panic than others. An article in Dive Training a year or two ago indicated that there is actually a test that can be given which is highly predictive of who will panic and who will not.
While Walter is correct about good training being an important part of reducing the likelihood of panic, most of the students with whom I have had to work with on this have problems from the very beginning, before there has ever been a chance to provide this training. Dealing with this begins in the classroom, where as an instructor you provide a calm and confident atmosphere. I also talk about breathing in general during class, including the effects of carbon dioxide buildup described above. I talk about the panic cycle directly. I have the students breathe with me to get a sense of how they should breathe underwater.
As the first pool sessons begin, you look for signs of nervousness, and, again, you keep the atmosphere light and positive. If you see potential problems develop, intervene early, but without making a scene. Take the troubled student aside to chat about how he or she is feeling. Reassure as appropriate. Often the student will come right out and talk about being anxious. That is a good time to talk again about the panic cycle and how to use diaphragmatic breathing to control it during the early stages.
The first time we submerge on scuba in the pool, we just relax and breathe. Once I see that everyone has settled in, I use my fingers to point out my own breathing patterns so that they can try to match it. Once again, I am looking for signs of trouble. Wide eyes and waving hands are something to watch for.
I find that if I follow the procedures I describe above, I almost never have a problem with a student.
Sometimes, though, it come out of nowhere. I once had a 16 year old girl who had begged her father for scuba lessons before an upcoming cruise. She got perfect scores on all quizzes and the exam, and she was obviously excited about being there. She was a good swimmer and an experienced snorkeler. When we prepared to submerge for the first time, she was thrilled that we were getting going after all that time with equipment setup, swim tests, etc. As soon as she submerged, she panicked. We came up, and she was crying. She had not had a flicker of fear until then. That was the toughest one I ever faced. It took a lot of sessions to get her through it, mostly because she was a perfectionist who saw her surprise panic as sign of weakness, and because perfectionists don't like signs of weakness, the fear that she would panic again was in itself a source of panic.