When you say “you are a good boy” to your dog, they get happy because they think YOU THINK you’re a good boy and they’re very proud of you for being confident and announcing you’re proud of yourself.
Me: “You’re a good boy!”
Dog: “Yes human, you are good. Good boy!”