I trackstand if I want to clear the intersection quickly, or I'm tired (so I'll screw up clipping in - easier to track stand than clip in), or the pavement is bumpy, or it's an uphill stop.
I unclip to practice clipping in, usually when I have less time pressure (quiet intersection, no cars behind me, etc).
Trackstanding is very similar to throwing your bike in a sprint. Both have the same basic principle - if you move a large mass (the rider) one way, and it's attached loosely to a small mass (the bike), the small mass will move in the opposite direction, but proportionately so.
If I move my body back 1" and my bike is 1/10th my body weight, my bike will go forward about 10". Likewise, if I let my body go forward 1" and I don't resist my bike moving back at all, it'll move back about 10". Ignoring friction, air resistance, etc, it's very basic physics - an action will have an equal and opposite reaction.
This means you don't need an uphill (crown of road etc) to do a trackstand. You just have to learn how to be able to move the bike backwards. That's the key - letting the bike move backwards.
The reason why bikes stay upright under most of us normal riders is you can steer while the bike moves. If you can't steer it's virtually impossible to balance (and, likewise, you "lose" your balance in order to initiate a turn).
(Bouncing the bike allows the rider to "steer" without rolling - instead of steering out of a lean, the rider just hops it sideways.)
By moving your body back and forth, you allow the bike to move forward and backwards. You can steer while the bike is moving forward and backwards. Therefore you can balance.
The reality is that a trackstand may involve moving the bike back and forth an inch or less (meaning your body barely moves at all) and you're barely steering. But it's about that roll - trust me, I can't balance on a non-rolling bike to save my life, but I can track stand for a long time.
Quick learners with a good teacher can trackstand inside of 15 minutes. Slow learners an hour. It took me 3-4 months of easy rides when I had tons of time (high school), maybe 3-4 times a week trying for 5-10 minutes.
cdr