I've been thinking about this topic for a few days now, and despite the tricks and often seemingly easy way that dog trainers can get dogs to behave in certain ways, there really is no magic in dog training. It looks so easy and simple when a knowledgeable handler is working with a dog - even a dog with little or no previous training. But there is no magic to what they (or I) are doing.
It's a very simple combination of two things: consistency and reading the dog.
Consistently communicating to the dog which behaviors will be rewarded or are preferred by the handler and which are prevented, interrupted and not rewarded. This includes not asking for behaviors that are beyond the skill level of the dog and not asking for behaviors if you are not prepared to switch to training mode if the dog doesn't respond correctly. If you ask for a behavior you have to be willing to work to get it, otherwise you're teaching the dog that your request was a suggestion at best and at the discretion of the dog at worst.
Reading the dog includes not just the dogs actual actions, but his body language as well - including posture, ear set, eye contact, exhibition of calming signals such as yawning, or stress signals such as lip licking. There are entire books dedicated to the topic of canine body language and how a single piece such as a wagging tail doesn't tell the entire story. A dog experiencing too much stress will not be able to focus on learning or performing a task correctly. It is the job of the handler to ask the dog to learn things in increments small enough for the dog to be successful with minimal stress - it maximizes the learning process and increases speed of training. A skilled trainer will be taking in the dog's body language communication and adapting to it as the training session goes. Challenging the dog to progress while at the same time, keeping the session rewarding and enjoyable for the dog. A happy worker is a diligent worker!
When done well it appears almost like magic, a rambunctious dog will rather quickly be walking on a loose leash. Or a very distracted dog suddenly becomes attentive to the handler. It's not magic, it's just consistency and communication blended correctly.