One start with a dog that actually wants to have their penis exposed to the light of day. Unless there is a physical problem like the sheath opening is to small, usually caused by neutering at a young age. the dog needs to be aroused, trying to force the penis out is rude and can hurt the dog, listen to the dogs wishes, read their body language. Is the dog telling you no they don't want you touching their penis and are doing all they can to keep it safely hidden in their sheath.
You've posted this question in the how to section, have a look through the guides here on how to masturbate a male dog and please if you can't read his body language enough to know if he is consenting or not learn how to do that first before you ever touch him.