What is the role of FEMA and other Homeland Security agencies when the event is caused by an act of terrorism?
FEMA, or Federal Emergency Management Agency, is primarily responsible for the response to disasters that have already occurred, which would include both natural and man made ones. We often think of only hurricane and flood response with this agency, especially given its association with Hurricane Katrina, but its role is to respond to a much wider variety of disasters than that. Should another 9/11-style attack happen in the US, FEMA would be one of the responders, under the jurisdiction of Homeland Security.
The Department of Homeland Security, meanwhile, is more concerned with national security. They work with the NSA and the CIA, as well as the FBI to share intelligence and try to prevent a terror attack from taking place. Once the disaster has happened, they are still responsible for security of the country and the affected area. FEMA is then brought in to distribute aid and provide food and medical attention. Immigrations and Customs, along with the Border Patrol, would seal the borders in the event of an attack, while the Coast Guard would protect America's shoreline.