The other answers cite minor effects related to your phenomena, but there's something more pervasive going on.
In Carney et al's research report "Power Posing: Brief Nonverbal Displays Affect Neuroendocrine Levels and Risk Tolerance", it was found that "power posing" increases testosterone and cortisol levels which leads to, among other things, a greater tolerance of risk in general — which is practically the definition of confidence.
Here's the abstract of their study.
Humans and other animals express power through open, expansive postures, and they express powerlessness through closed, contractive postures. But can these postures actually cause power? The results of this study confirmed our prediction that posing in high-power nonverbal displays (as opposed to low-power nonverbal displays) would cause neuroendocrine and behavioral changes for both male and female participants: High-power posers experienced elevations in testosterone, decreases in cortisol, and increased feelings of power and tolerance for risk; low-power posers exhibited the opposite pattern. In short, posing in displays of power caused advantaged and adaptive psychological, physiological, and behavioral changes, and these findings suggest that embodiment extends beyond mere thinking and feeling, to physiology and subsequent behavioral choices. That a person can, by assuming two simple 1-min poses, embody power and instantly become more powerful has real-world, actionable implications.
Their paper explains both the ontogenetic and the phylogenetic causes of your experience nicely and can be found here.
Cheers.