Male dogs lift their leg when they pee to mark their territory. If a dog sees other dogs doing it and then he goes over and sniffs he will naturally associate that in order to get my scent "that high", I need to lift the leg. He may also smell a scent of a male that came before he did and he will want to cover the other scent with his.

If you have a dog that shows any sign of dominance then they will most likely start lifting their leg anywhere between 8 and 16 months old. If they haven't by this time then they probably won't and in most occassions will not be territorial.

You will find that male dogs can go about as many times as there are obsticles to mark!! It is usually done as a territorial trait! Having them nuetered is not a guarentee that they will not have some dominant characteristics that will cause them to be territorial. Getting them neutered if they are dominant is strongly recommended though since it will ease extra hormones from coming into play.