Sounds like you're normal, but you freaked out a little too much. The very second time you tried to have sex you were on a prescription ED drug? That sounds drastic and it sounds like your doctor is just handing them out. It's a drug for ED, which you don't have. You're able to achieve erections when masturbating and even with girls, and the doctors check up was normal, you don't have ED.
You're problem seems to be psychological. Healthy living, diet, and exercise are great for that like Stan mentioned. You could also go to a therapist like Llewellyn mentioned, if it's a real big problem for you. Do you have anxiety in general, or only in this situation? If in general, then you should probably seek help from a therapist or your doctor. I had anxiety as a result of a stressful health condition and was given anti-anxiety and anti-depressant meds. I wanted off so I used the program you see advertised in infomercials late at night for Attacking Anxiety And Depression. It works well, and is the most natural as it only involves changing your thoughts, exercising and removing some bad things from your diet. I also found Amoryn and Serodyn, natural products, work great as well without the side effects of the prescription drugs.
If your anxiety is only in these sexual situations, then talk with a therapist or sexual therapist could help. However, you might not need that. Like I said before, you sound normal, you just freaked. You worried about ED, because you lost your erection your first time. Guess what, that's normal. Many men have some difficulty with erections their first few times with a new woman. Erections may be weaker, fade quickly, or even leave. The trick is not to worry about it, but that's easier said than done right. If it happens, be honest with the girl, let her know you might just be a little nervous and this happens naturally as a result. Then do something else such as please her and she'll have a good time. Sooner or later you'll feel more comfortable with her, she won't abandon you because of it, and you won't have the problem anymore. You don't want to sit there and try to get an erection from touching yourself, or having her do it if it's not working. Erections come from arousal and the mind, so over stimulation would only make you worry about it more when you see that it's not working.
If it helps you can build a relationship before you even get to sex and it'd be easier to explain, because you care about each other. However, if I were you I'd bite the bullet and go back to the girl you had problems with recently. Whether you want to explain why beforehand, or just put yourself into the sexual situation and see what happens, is up to you. If it doesn't happen, you're good, if it does, you can explain it then. Nerves can definitely effect erections, even if you feel calm. The good thing is, nerves settle. Sometimes in one session, sometimes after several times and you get to know each other better, what to do, etc. I also find honesty to settle nerves. If you're hiding you're feelings, you're inside yourself worrying, wondering what's wrong, wondering what she's thinking. If you talk about it, you'll see her calm and accepting response and that should calm you. You'll probably also find that she was worried too, thinking it was her, and in effect you'll be calming both of you. So try not to worry about, talk to her about it, be honest and if it happens continue on and have fun other ways. Staring at your penis, concentrating on getting erections and stimulating just doesn't always work. Letting yourself relax and casually thinking about things that arouse you do often work. Such as watching her, looking at her body, thinking about what you want to do to her, how it's gonna feel, etc. Just don't concentrate on it like you're trying to get an erection. The erection is what happens, it's not what you're aiming for.