Author, David Talbot, suggests that the Bay of Pigs was intended to fail.
The assumption was that the failure and embarrassment would forced JFK to escalate US military intervention in Cuba (Kennedy of course pissed off the CIA by refusing to get militarily involved in Cuba).
Similarly, it's plausible that the Pentagon intentionally screwed up the withdrawal logistics because most of the Pentagon brass oppose the Afghanistan withdrawal policy.
Either way, I'm glad that Biden isn't listening to the Generals who are corrupted by Defense Contractors and war profiteering.