I believe the key to this is arousal. Not just being erect, but long-term, sustained arousal, which is what edging accomplishes.
I’ve found that if I spend a sufficient amount of time stimulating myself or with a partner, that after releasing I will often stay hard without even thinking about it. I’ve experienced times when I could come several times over and stay hard indefinately.
If you are arousing yourself, spend about 20-30 minutes just stimulating your dick and keeping it hard. Don’t try to go straight for an orgasm, just tease and keep the arousal going. If you are with a partner, insist that she/he takes the time to get you sufficiently aroused and explain to them the importance of it. This is what is typically referred to as foreplay. I know its obvious, but I think most people regard foreplay as just whatever it takes to get a guy hard or a woman wet and then going for it.
If you spend more time getting each other turned on it will pay off farther on in the process.