We support middle eastern terrorist states(Egypt, Saudi Arabia). We dropped Afghanistan on it's rear the second the Soviets pulled out(and let islamofacsists take over). We backed Saddam in the Iraq-Iran war. We supported the Israeli occupation of Palestine. I fail to see how any of these actions would do anything but encourage terrorism. Having said that, when you have alot of power, and you use it to influence conflicts, the side that wasn't backed and their sympathizers and backers, are, of course, going to less than happy with you.
Bottom line though, we are the 800lb gorilla in the room when it comes to the world stage, and as such we make a great target. With any missteps we are going to trod on someone's toe, giving them a reason, in many cases justified, to be angry with us. Given our active role in influencing world affairs, and taking into account that no one is perfect, messing up in inevitable. What I think our greatest problem with respect to our foreign policy is our eagerness to shrug off mistakes and label them as inevitable and thus irrelevant. If someone bombed the terrorist down the street, and killed my sister/brother/mother/cousin/uncle/aunt/whatever in the process, and said "oh well, it happens.", I'd have a perfectly good reason to be angry. Add to that that it was done by foreigners, ignorant of my culture, language, and history, and it's just salt in the wound.