That's mostly because transport companies have to pay to ship you back if you get turned away at the border, so they will want to see your permission to enter your destination country before you leave. I've traveled internationally a fair bit and I've never had to show my passport to government officials when leaving the US.