Urine on vertical surfaces disperses smell better. It's for communicating with other dogs.
Leg lifting shows confidence and marks territory. Intact males do it most.
Most male dogs start leg lifting around 6 months old when reaching sexual maturity.
Neutered males tend to leg lift less frequently, but still use it communicate with dogs.
Train your dog not to urine mark in the house. Praise outdoor peeing only.
Thoroughly clean indoor accidents with enzymatic cleaner to remove odors that attract marking.
Block off furniture and household items you don't want leg lifted on.