Why do beavers build dams?

A beaver stands on top of its dam. (Image credit: Troy Harrison via Getty Images)

Beavers are renowned for building dams, which the animals construct from trees and branches they cut using their strong front teeth, according to the National Park Service (opens in new tab). The rodents also use grass, rocks and mud to reinforce these structures. 

But why do American beavers (Castor canadensis) build dams? Do they live in them?