Practice makes perfect. Edging often is the key, you need to learn to repeatedly get close to orgasm and then back off.
I can have several small orgasms in a session, cumming a little bit each time without losing my erection, and if anything, it usually gets harder after each orgasm. It's messy but it feels amazing.
Because I have conditioned myself to be able to do that, it's not uncommon for me to have a full orgasm and stay rock hard after, even if I'm not edging. I can then bust a huge nut again, and once in a blue moon I'll still be super hard and then I can cum a third time.