Its training, nurture, consistency, routine and example from day 1.
Rigid boundaries, positive behaviour reinforcement and they soon learn. They're very intelligent animals and live to please humans.
That said, the job is even easier for me this time round as Bruce is a well behaved, mild mannered and instantly obedient dog and Geddy is quickly learning from his example.
You do get some loons that are harder work, but the fundamental part of their character is for us humans to mould.