Dogs don't know right from wrong. They do not share our values or morals so their sense of right and wrong in the way we see it does not exist. They do not have that ability. If you think that your dog "knows" that he did "wrong" you are mistaken. Dogs only know safe or dangerous. It's safe to go to the bathroom or it is not safe. If it's not safe, a dog still has to go, but he will hide it. The only way to teach a dog to be housebroken is to prevent accidents by constant supervision while the dog is loose in the house. And to give ample opportunity for success and reward lavishly....in other words reinforce the correct response. Punishment, even as mild as showing them displeasure will tend to shut a dog down....keep him from trying to guess the correct response and cause him to be apprehensive of his owner.
When people say, "My dog looks guilty. She knows she did wrong when I come home and find poop." Well, that is untrue. The dog has experienced enough times that the owner came home and was displeased or angry that the owner coming home is a predictor of a worrisome or anxious time for the dog, hense the look of "guilt"...the lowered head, the slinking body language. I'm not saying your dog is doing this. I'm just trying to get it across how we can misconstrue what is going on in a dog's mind.
I am not saying that you used punishment. How would I know? I'm just brainstroming here, and coming up with the usual reasons for dogs who hide their accidents or don't go when taken outside very well. If they have associated the owner's displeasure at their going in the house, they may take it to mean that going to the bathroom is not safe, not that going to the bathroom in the house is not safe. They don't think about outside, inside until they're trained well. If they're punished, it all boils down to: it is not a safe thing to go to the bathroom. So, they hide it because of course, they can't hold it forever.
This is why behaviorists and trainers now urge people to supervise very, very carefully, crate when the dog can't be watched, take the dog out very often, praise the instant the dog is finished and give a treat. You have to prevent accidents or the dog will repeat that behavior and if there are accidents, it's not the dog's fault. It's ours. So, have patience and don't worry about peoples' explanations here. No one means anything but to help. You may be taking it the wrong way. No one accused you of anything. It's all guess work and surmizing here since we're on the Internet. These are the typical reasons based on animal behavior that usually cause the problem you're describing.