The US National Security Agency (NSA) broke privacy rules and overstepped its legal authority thousands of times in the past two years, according to documents leaked by Edward Snowden.