Just so you know, a puppy is never completely housetrained until they are 6 months old. For some breeds, even later. This means that though you may be making tremendous progress housetraining, there will be "mistakes". Sometimes for reasons you can't figure out! Don't fret about it. Stay focused on the progress you are making. Your confidence in the techniques you are using to house train your puppy will ensure your success.

Let your new dog gradually earn freedom throughout your home. A common error that many pet parents make is giving their new dog too much freedom too soon. This can easily lead to accidents relating to housetraining and destructive chewing. So, close off doors to unoccupied rooms and use baby gates to section off parts of the house, if necessary. One of the best ways to minimize incidents is to keep your dog tethered to you in the house and by using a crate or doggie safe area when you can’t actively supervise him.
Operant conditioning (or instrumental conditioning) is a form of learning in which an individual's behavior is modified by its consequences. Two complementary motivations drive instrumental learning: the maximization of positive outcomes and minimization of aversive ones.[39] There are two ways in which behavior is reinforced or strengthened: positive reinforcement occurs when a behavior is strengthened by producing some desirable consequence; negative reinforcement occurs when a behavior is strengthened by avoiding some undesirable consequence. There are two ways in which behavior is decreased or weakened: negative punishment occurs when a behavior is weakened by not producing a reinforcing consequence; and positive punishment occurs when a behavior is weakened by producing a consequence that is a disincentive. In combination, these basic reinforcing and punishing contingencies provide four ways for modifying behavior.[40] Reinforcement increases the relative probability or frequency of the behavior it follows, while punishment decreases the relative probability or frequency of the behaviour it follows.

On a side note, a puppy’s mother can actually do a lot of the potty training for your dog. I know of several reputable breeders who tell me that the mother dog trains their pups not to eliminate in their nests. From the moment a puppy is born its mother is teaching it that the NEST is the place where it eats & sleeps. One of the first rules Mama Dog starts to teach her pups is NO peeing or pooping in the family nest – That’s Disgusting! And she makes them follow her outside.

In the 1950s Blanche Saunders was a staunch advocate of pet-dog training, travelling throughout the U.S. to promote obedience classes.[17] In The Complete Book of Dog Obedience, she said, "Dogs learn by associating their act with a pleasing or displeasing result. They must be disciplined when they do wrong, but they must also be rewarded when they do right."[24] Negative reinforcement procedures played a key part in Saunders' method, primarily the jerking of the choke chain. The mantra taught to students was "Command! Jerk! Praise!" She felt that food should not be an ongoing reward, but that it was acceptable to use "a tidbit now and then to overcome a problem." Saunders perhaps began the shift away from military and police training methods, stressing repeatedly the importance of reinforcement for good behaviour in training—a move toward the positive training methods used today.[25]
One of Millan's many dogs, Daddy, was an American Pit Bull Terrier integral to Millan's work and his television series, The Dog Whisperer.[49] Millan later selected another pit bull puppy, Junior, as Daddy's protégé — to apprentice, learn his temperament and prepare to assume Daddy's role after his death.[50] Daddy's death came at age 16 in February 2010.[50] After the death of Daddy, Junior assumed Daddy's role and helps Millan with rehabilitating dogs by using what Millan refers to as calm, assertive energy.[51]
There is only one acceptable methodology for potty training a dog of any age: positive reinforcement. Traditional advice suggested swatting a dog or rubbing his face in his waste for mistakes in the house, but those techniques do nothing to make the potty training process more understandable for your dog and can actually damage your relationship with him. Keep in mind, dogs don’t view their waste the way we do – to them, pee and poo is pretty interesting! Punishing your dog for going in the house won’t help him understand what he should do instead and might make him afraid to go near you at all, inside or out. Successful potty training requires patience, kindness and remembering that your new puppy is just learning the rules.
In one study laboratory-bred Beagles were divided into three groups. Group A received an electric shock when the dogs touched the prey (a rabbit dummy fixed to a motion device). Group H received a shock when they did not obey a previously trained recall command during hunting. Dogs in group R received the electric shock arbitrarily, i.e. the shock was administered unpredictably and out of context. Group A did not show a significant rise in salivary cortisol levels, while group R and group H did show a significant rise. This led to the conclusion that animals which were able to clearly associate the electric stimulus with their action, i.e. touching the prey, and consequently were able to predict and control the stressor, did not show considerable or persistent stress indicators, while animals that were not able to control the situation to avoid the shock did show significant stress.[66]

Young puppies can’t hold their bowels & bladders for long. If you come home to find that they’ve had an accident in there it’s quite possible that they can’t hold it that long. Generally puppies can hold their bladder for about one hour per month of age. So your 3 month old pup can probably only hold their bladder for about 3 hours. If you’re going to be away at work for long periods of time see if you can get a neighbor, relative or dog sitter to come over to let your pup out during the day.
A dog learns from interactions it has with its environment.[1] This can be through classical conditioning, where it forms an association between two stimuli; non-associative learning, where its behavior is modified through habituation or sensitisation; and operant conditioning, where it forms an association between an antecedent and its consequence.[2]