With respect to the Charter of the UN:
Nothing in the present Charter shall impair the inherent right of individual or collective self-defense if an armed attack occurs against a Member of the United Nations...
So, in general, the UN is fine with a nation defending itself. How one defines "self-defense" is, of course, up for debate.
UN involvement in the Korean War was authorized by United Nations Security Council Resolution 84 and United Nations Security Council Resolution 85.
US military involvement in Vietnam (and later further in Laos and Cambodia under Nixon) is rooted in the Gulf of Tonkin Resolution. Essentially, Congress gave President Johnson the power to use military force in Vietnam in order to defend South Vietnam.
The 1991 Gulf War was authorized by the Authorization for Use of Military Force Against Iraq Resolution of 1991
The 2001 invasion of Afghanistan fell under the Authorization for Use of Military Force of 2001, and of Iraq in 2003 with the Authorization for Use of Military Force Against Iraq Resolution of 2002
Further justification for the use of military force is the War Powers Resolution
As for the why, I suspect that you'd have to ask each member of Congress who made each vote, and I imagine that you'd get a variety of responses ranging from:
- Attempt to limit the president's authority (see how Congress reacted to Nixon expanding the Vietnam war into Cambodia and Laos)
- The US can use force anyway so it doesn't matter what Congress calls it
- Ceding war and military conflict powers to the President pushes the blame in that direction as well (e.g. one can imagine a Congressperson telling the press "We gave the President the authority to defend our troops only in Vietnam and he went and invaded Laos! You can't blame us for those negative things")