WHY!!!!!!!!! 😖😭😖

Hannah •
So I have a four year old Chihuahua mix and I've had him roughly two months but every time my fiance and I put him in the other room, shut the door, and try to have some alone and intimate time he poops and or pees in the house what can I do to keep this from happening? Just a side note I had taken him out just before this happened.