the taliban made themselves americas problem to fix when they decided to shelter bin laden (the man who had just orchestrated the single biggest attack on america since pearl harbor)
the big mistake here was staying for a prolonged occupation, even after bin laden had been taken. the proper way to go about it would have been to just pack up and leave immediately after that guy was in the ground, instead of staying and fucking around for another decade after that.
iraq is less clear cut. originally saddam made himself americas problem to fix when he invaded and annexed kuwait in 1990, which triggered the first gulf war, but for some reason bush sr did not actually follow through, he just drove the iraqis out of kuwait and then fucked off, leaving saddam alive and his regime intact. 2003 was W deciding to finish the job his dad had started and left unfinished.
the big mistake in this case was not finishing off saddam in the first war. coming back a decade later (and then getting involved in yet another decades long occupation) was retarded as fuck, and W's war in 2003 had a lot less support and legitimacy than bush seniors war had in 1991.