The Gist: A big flaw in the security that TOR provides is JavaScript, if you have it enabled, the websites you visit can still track you. The FBI essentially exploited the problem and installed a tracking cookie if you had JavaScript enabled, allowing them to gather your IP address and location when normal browsing was resumed.
TL;DR: It was their own fault, it was a well known flaw in the security.