When docile, the penis remains in the dog's sheath to keep it sterile, moist, and protected. The penis usually leaves its sheath when the canine is aroused (not to be confused with erect) or when he is thrusting.
The penis itself is usually red or pink in color and is composed of a membrane layer that is similar to what's on the inside of your mouth. It does not become 'erect' until after successful penetration. Instead, the stud's penis maintains its shape with a bone called the baculum.
When finally "erect", a thick "knot" at the end of the penis fills with blood and swells several times its flaccid size. This is called the Bulbus Glandis, and it keeps the male dog tied -- or knotted -- to the female dog, which prevents any reproductive liquids from leaking, thus improving the chances of a large or successful litter.
Finally, a male dog's penis does not feel pleasure in the same way that a human penis would. Where stroking of human's penis (i.e. by a hand, vagina, mouth, etc.) brings pleasure to the man, the opposite is true for a canine, as it'd only cause discomfort and irritation if prolonged. Instead, the stud's penis responds mostly to pressure behind its bulbus glandis, which insures that the knot stays 'erect' when the female's vulva is clenching behind it.
Educated friend: That's just his canine penis being forced out of its sheath by his baculum because he's sitting down.
Uneducated friend: Dude, how do you even know all that? You must be some zoo weirdo.
Educated friend: Please bury yourself in a hole and take your prejudice with you.
Uneducated friend: You're just offended because you're a zoophile!
Educated friend: It's idiots like you that keep science and education from advancing.