Sometimes it's just pyschological, nervous can make you 'turn soft' easily. If you can get hard on easily but turn soft easily, maybe you were just nervous.
But still, drugs can help in this case to build up your confidence.
Reply to srocco, it's easier to keep hard on when masturbating, doing sex with a partner is not only a bit more stressful, but can also be distractive or 'service rather than enjoy'.
If you have a real functional ED in 20s, maybe you don't need to worry about damaging your erection function later on, because even you don't take pills now, you will still have problem later anyway.
My advice would be trying from very low dosage: 2mg 4mg ... in younger age, even 2mg dose can make a difference. And don't use it when you are not going to have sex; I personally found tolerance built up quickly if you use it often.