Thank you for asking your query.
Loosing erection while putting on a condom is a common occurance among young people. Loosely termed as condom collapse syndrome, this is almost never because of any physical illness, allergy or organic cause. All the reasons which can cause psychological erectile dysfunction can cause this problem. Since condoms act as a barrier it slightly brings down your pleasure senses. I will put it like this if you are 5x physically stimulated with condoms it will be 3x. So if you are only 3x ; physically stimulated?
So it just means when you are less physically stimulated, or when there is stress, anxiety, or uneasiness put on a condom and it will go down.
The solutions are
1. Clearing up your head, staying positive. May be more emotional intimacy with the partner.
2. Try a different brand, larger size of condom.
3. Let your partner put on the condom for you
4. Try having the condom early on. You can have them on during foreplay, not just before the act of intercourse.
Whatever is the case, this is a passing phase. Please follow the recommendations; everything should be alright in less than a week.
Hope this helps.