It is mostly due to performance anxiety
Thanks for your query,based on the facts that you have posted it appears that you had problem in penetration of vagina during your first sexual intercourse with your girl friend and lost the erection.
This is natural to happen during beginning of sexual life and there is nothing to be worried about.In absence of any major health issue the cause of loosing erection is mind related and due to what is called as performance anxiety.
Following measure will help you to boost up your confidence and getting good sustainable erection.
1) Practice regular exercise for 45 minutes followed by meditation
for 1/2 an hour in the morning.
2) Take high protein diet rich in vegetables and fruits and Vitamin A
3)Take anti oxidants like Almonds 5-6 everyday..
4) Avoid alcohol and smoking
Take your girl friend into confidence and both of you consult qualified Psychiatrist
(Viagra) will help you to get good ,hard .sustainable erection.
Please get prescription from your family physician.
Please do not worry this problem will get resolved itself.
Hope I have answered your query ,please feel free to ask if you have more questions ,I shall be happy to help you
Thanks and Regards.