No you don't have to have an erection, it's just another way of "working out" your PC muscle.
Basically, stop your urine mid-flow. The muscle you contract to do that is your PC muscle and what we call a "kegel".
If you get an erection, flex this muscle. Can you see your penis moving...bobbing up and down? If so, then you've isolated the right muscle. If you have a very hard erection, another way of working out the PC muscle is to drap a towel over it which will weight it down and point it straight out rather than straight up. Now flex your PC muscle and lift the towel and your penis back up.
It's just another way of exercising