Why? Just why would you put it back in the box and just leave? Why didn't you ring the doorbell or text the customer to let them know what happened. You could have also contacted DoorDash and told them what happened and set it up to go and get another pizza. But, no you just put it back in the box and leave.
However, maybe he was a new driver to the app and wasn't really sure what to do so he just panicked and left. Either way the right thing do would have been to tell the customer what happened and from there.