Because you have many different classes of troll. All with varying levels of sapience. 

**Stone-trolls** were trolls who turned into stone during daylight, like the trolls in The Hobbit. They could speak, and used a debased form of Westron.

**Hill-trolls** are described in the chronology at one instance as having killed Arador, grandfather of Aragorn. Tolkien described the trolls of that region, including the three from The Hobbit, as stone trolls, suggesting that hill trolls might be a subclass or alternate term for such. However, the Army of the West fought "hill trolls" of Gorgoroth that could move in sunlight at the Black Gate, inferring that these hill trolls, at least, were Olog-hai rather than stone trolls. Hill trolls hardly differ from stone trolls and were probably of the same beast-race.

**Cave-trolls** were seen in Moria, and were also in the Ettenmoors. One was described as having dark greenish scales and black blood. They have a very thick. During the fight in Moria, Boromir struck one on the arm and his sword became notched and no damage was done to the Troll. 

**Mountain-trolls** were mentioned once, wielding the great battering ram Grond in shattering the gates of Minas Tirith. From their name, they are generally assumed to live in the mountains, and their choice as the creatures to wield Grond is sometimes taken to suggest that they were particularly strong even for trolls.

**Olog-hai** were "strong, agile, fierce, and cunning" trolls created by Sauron, not unlike the Uruk-hai, and were able to withstand sunlight while under the sway of Sauron's will. They were also able to speak, but only used the Black Tongue of Mordor.

**Half-trolls** were troll-like humanoids from Harad who served Sauron in The Battle of the Pelennor Fields. While it is unlikely that they had any actual troll blood in them, it is still possible (but more likely they were a superior breed of orcs and/or men). It is assumed these could also speak.

---
<sup>*Disclaimer: The above information is mostly taken from the [LOTR wikia page on Trolls][1], but enough of my commentary is included that I don't feel comfortable block quoting it.*</sup>


  [1]: http://lotr.wikia.com/wiki/Trolls