There are two factors I see a lot that might be at play here.
First, it might be that you're having trouble with problem-solving -- that is, you can do all the steps when the instructor is walking through them, but deciding which steps to take on your own is hard. If that's the case, I recommend practicing more with problems; for example, try solving homework problems without making use of any notes that you won't have access to on the exam. Or, if you've finished the homework, try changing the problems you were given slightly (change a 5 to a 7, for example) and solving them again.
The second possibility is testing anxiety - some students find that just taking a test makes them nervous, and being nervous makes it hard to do math. If that seems like it describes you, I have two recommendations. First, when you study, try to simulate a testing environment for yourself - for example, do practice problems on a timer, while sitting at a desk. Second, you may want to talk to a counselor (many schools have counseling centers available to students) about general strategies for controlling anxiety.