If i am not mistaken , your dog is a male, hes try to mark his territory. At some place, he started having a feeling of threatened , so what is try to do is not urinating actually hes marking the territory.
Make him feel home, dont let him feel hes the alpha dog of the pack, sometime certain male dogs do this, try to show the dominance , show him whos the master. To start with try giving him less water, take him out immediately after giving him food and water, take him for a long walk (like 20-30 Mins).
As far as training dogs are concerned you need to be consistant and regular, slowly they will start responding.
Hope this helps