When you wake up with an erection, you've been dreaming and have probably had a full erection for several minutes. There have been no physical or other distractions.
Fast forward. You've gone to the toilet (not the most erotic thing for most people) and started to masturbate somewhere. If it's the bathroom, it's not the most comfortable of places. If it's back in bed, you've had the assorted distractions and it can take time to get fully focused on what's happening. You're probably not totally turned on - if you were, you'd probably have the erection before you started playing with it, and probably wouldn't lose it as quickly when you ejaculate.
If you want the experience of playing with a fully erect penis, having woken up with one, you could a) masturbate first, then go to the toilet, or b) wait until you're seriously horny.