Grim Statistics: Data on US war casualties
For detailed data concerning military deaths over the past 15 years, check out this article from the Congressional Research Service.
https://sgp.fas.org/crs/natsec/IF10899.pdf
Overall Deaths in Afghanistan
Since 2006, approximately 2,004 U.S. troops have died in
Afghanistan. Nearly half (46%) of all these military deaths
are attributable to IEDs and their variants, which took their
greatest toll between 2009 and 2012. Most U.S. personnel
not killed by IEDs during this period died as the result of
gunshot wounds, or after suffering other multiple physical
trauma in action (529). Between 2006 and 2021, a
substantial number(168) died in connection with the loss of
an aircraft or ground vehicle.Most such incidents were
classified as accidental (70%), and occurred under
nonhostile conditions.
More on all recent wars at the article's link:
https://sgp.fas.org/crs/natsec/IF10899.pdf
Also, a good chart of Hostile Military Deaths Overseas since 2001 can be found in this article:
https://www.militarytimes.com/news/your-military/2021/05/31/a-year-without-combat-deaths-this-memorial-day-military-fatalities-overseas-were-the-fewest-since-911/