After the attacks of September 11, 2001, the United States was poised to find and "bring to justice" the perpetrators and planners of such an action. When it was revealed that Osama Bin Laden and the al Qaeda represented the active organization that had planned and executed the attack, the natural question had been where these individuals were in the world. When the government of Afghanistan, a regime of the Taliban, had stated that they were providing sanctuary to the group, the United States and its coalition of partners felt driven to attack in Afghanistan and find the "criminals, dead or alive." The attack in Afghanistan uprooted the fundamentalist Taliban regime and allowed a theoretical notion of democracy to be present in Afghanistan. After retreating to the mountainous ends of the Afghan and Pakistan border, Coalition forces were unable to find bin Laden and other high ranking al- Qaeda officials. The search goes on even today.
There are several clarifications that need to be made to your question.
1. The U.S. and England were not the only countries to send troops to Afghanistan in 2001/2002--to this day, there are many NATO countries with troops in the region.
2. The U.S. did not attack Afghanistan. It attacked Al Qaeda--a global terrorist organization which had its base in Afghanistan at the time--and the Taliban, the radical ruling group of the country which oppressed its own people and willingly gave shelter to Osama bin Laden and Al Qaeda.
3. In 2001, the United States and England began working with many native Afghans to rid their country of terrorists and to place the decision-making process back in the hands of the Afghan people not in the hands of an elite few who terrorized their own countrymen. Many of the Afghans who assisted and who still assist U.S. forces were followers of Massoud (an Afghan leader who fought against the Taliban until he was assassinated two days before 9/11), and they would not see the U.S. and England as attacking their country.
I guess this is receding into the past so quick that I shouldn't be shocked at this question. If you are in 12th grade now you were in 3rd then... Okay, well for the answer:
The US attacked Afghanistan in 2001 because of the 9/11 terrorist attacks. The attacks were carried out by Al Qaeda, a terrorist organization that was, at that time, headquartered in Afghanistan. The Afghan government (led by a group called the Taliban) had allowed Al Qaeda to stay in their country and run terrorist training camps. The US attacked Afghanistan to prevent Al Qaeda from being able to stay there and continue to have a safe haven. By doing so, we hoped that we would be able to prevent Al Qaeda from launching further attacks.
We also hoped to catch the head of Al Qaeda, Osama bin Laden. That did not happen.