There are two assumptions that humans make about their dog's bad behavior. The first is that humans assume that dogs know when they have done something wrong. The next assumption is that humans believe that dogs may act out as a way to get revenge on their owners. While we don't always know what dogs are thinking, it's pretty clear that dogs don't act badly out of spite and dogs aren't always aware when they have done something wrong.
Let's say you come home at night, and your dog has strewn trash all over the kitchen floor. You react to the mess. Perhaps you say loudly, "Who did this?" or "Why did you do this?" You don't pet the dog as you normally do, and you remain silent as you clean up the mess.
The dog isn't necessarily feeling guilty about stringing out the trash. However, the dog can pick up on the fact that something is off. If your dog is familiar with you and how you react in situations such as these, then he or she knows that you are feeling different. You're not your usual happy self. You aren't offering hugs, cuddles, or treats. You're acting different, and your pet picks up on this, and it makes him or her feel different as well.
This doesn't mean that your dog feels guilty. Your pet doesn't think, "I strung out the garbage. It was bad, and she is mad at me." Instead, your dog picks up on your feelings and knows that it has done something wrong. Your pet doesn't have reasoning skills to logically think, "I did this. She is mad. I feel bad about it."
The dog doesn't understand why it should feel bad, so it doesn't feel guilt. In this example, your pet doesn't know that you dislike picking up garbage, you're tired from work, and he's spread erms everywhere. While dogs are smart, they aren't smart enough to have the same reasoning as a human, and thus, it's highly unlikely that your pet feels guilt.
Likewise, your pet isn't doing this just to spite you. For example, if you went to bed early without playing with your pup, he isn't going to go through the garbage just to "get you back." The two behaviors are not connected. Maybe the dog smelled food in the garbage and wanted to see what he could find. Maybe the lack of playtime left your pet bored. No matter what the reason, though, pets aren't spiteful to their owners.
In any of these scenarios, your dog may have a look of guilt, which could lead you to believe that he feels bad for what he did or that he did it out of spite to you. Neither of these feelings are true. Your dog picks up on your words, actions, and body language and knows that it did something wrong. However, it does not connect the dots to understand why or to have remorse for what it did. Instead, your dog is simply showing its own emotions in its own ways - a wary look, a dropped head, body language that's askew - because he feels frightened, confused, or nervous.