In a word "Pavlovian".
I used to share a home with a bullmastiff, Misty. For a number or reasons, Misty had to be outside during the day while everyone was at work. She had a nice dry dog house and blankets, but as short haired dog, I imagine it still got cold on occasion.
Sometimes her teeth would chatter, like a person does when they are cold. I often felt guilty about making her go out in the cold. If there was snow on the ground and she had to go out to go pee, her teeth would sometimes be chattering when she came back in.
Then it got to be spring and then summer, hot in the house and hot outside too. Once or twice a week in the dead of summer, the call to go outside would result in chattering teeth.
I realized it was not the temperature outside that made her teeth chatter, it was the association of one thing to another. In this case there was a pretty clear association. But the association is not always clear.
Pets like people often come into our life with a little baggage (in the emotional sense). Do your best to continue to provide a stable and loving relationship, remind yourself that whatever your pets life was like before, it much better now. Maybe the shaking will go away and maybe it won't, but as long as both you and your dog know that you are both doing your best...