How do you make your penis stay erect?

Erections are all about physiology and psychology. If your brain is stimulated an erection will develop. That stimulation can come from any of your senses.
Some people are stimulated by music, naughty talk or the sounds of sex. The smells of sex or something that your brain associated with sex, perhaps perfume or a smell you remember from a previous sexual experience. Touch is powerful and certainly your own touch can stimulate you but likely the touch of another will stimulate you more. We are very visual creatures and seeing sexual objects or activities will stimulate you, that's evidenced by the world of porn we are awash in.
If you are young and having trouble keeping an erection, that would be a bit unusual and could be over stimulation, guilt, too much masturbation or even physical problems with your circulatory system.