People here keep citing the wargames with retired Gen. Riper, who sank the USN repeatedly from the perspective of a non-peer adversary using non-technological methods to organize, and disposable, low value swarming assets to overwhelm American defenses. Both Iraq and North Vietnam had patrol boat navies and the wherewithal to invest in attacking a carrier, but didn't.
I guess the simplest answer is they didn't launch an attack because they couldn't. Specialized torpedo boats cannot generally penetrate a destroyer or cruiser screen without assistance. There is no viable way to even get into position to threaten a carrier as such a movement will be detected on radar long before a threat materializes. Even when American ships engaged in offensive operations close to the north Vietnamese coast they came out on top in clashes involving patrol boats making a large offensive operation unappealing.
The red force in the millenium challenge had access to significant capabilities that Iraq and Vietnam did not have access to such as incredibly accurate anti-ship cruise missiles.