My son did this a lot - so often, in fact, that we called our back deck by the nautical term "poop deck" ;-) It's important to wait and see if this is a pattern, or a unique occurrence in your son.
We found that it had a lot to do with not wanting to stop what he was doing - he would squat down to play with his trucks, and nature took its course. Of course, peeing outside has its own fascination - playing target practice with a tree, etc. I think some of it is a very normal phase and it's important not to overreact to all of it. Guys "go" in the woods all the time on camping trips, and of course he sees the fascination of the dog doing it. I think it is important to distinguish between peeing in the sandbox and peeing at the edge of the property. (By the way, be sure you cover your sandbox every night to discourage animals from using it as a litter box!) Not that you want him peeing in the sandbox, but (according to Dr. Oz on the Oprah show)urine is actually sterile - medics on war zones are told to pee on soldiers' wounds if no other fluid is available to wash them out. Poop, however, is full of bacteria.
Putting the little potty outside might work - and making him help to clean up his accidents might make him realize that it's more work to do it his way than to do it the other way. I would try to do this without too much aggravation or anger - just matter-of-factly help him dispose of the poop in the indoor potty (where he's winding up no matter where he poops, see?), wiping himself (get those personal cleansing wipes, for kids or adults - much easier and more effective than toilet paper - I find the Cottonelle ones with the dispenser are easiest for little hands). Then he has to wash up WELL because of bacteria. He also has to clean the deck - set aside a special brush and detergent for this.
He will learn in preschool that kids use the potty. He will not go to kindergarten pooping in the playground. In the meantime, you can also set aside some treats or a sticker system for each time he uses the potty, and make it clear that you don't have as much time for fun things when so much time has to be spent cleaning the deck. Bottom line (no pun intended), you can't force this, but you CAN influence him. He can also be given a big-boy treat for each week of successful potty use, but you have to be sure he can handle delayed gratification.
The "you can, you just won't" thing is a whole 'nother topic for another day! Been there!