In the case of Iraq, they lied on purpose to support the invasion. In the case of Iran, Trump just ignored the intelligence.
I do think the intelligence community is capable. For example, they warned of the Russian invasion weeks before it happened when all other European countries said it wouldn’t.