From Merriam-Webster's definition of dam:
1 : to provide or restrain with a barrier that prevents the flow of water : to provide or restrain with a dam …
// dam a river
2 : to stop up : BLOCK
// damming up their emotions
Although up doesn't need to follow dam, it often does, and dam up has become a common phrase.
According to Google NGram Viewer, dam on its own is twice as common as dam up in print, but dam up is still used:
Verbs are often followed by prepositions even when they don't have to be, because they add to (or emphasize) the mental picture of what's going on.
In this particular case, stop up (which dam is synonymous to) actually requires up to be meaningful in this sense. You would not normally say that the drain is stopped but that the drain is stopped up. If we are used to using stopped up, it's not that strange to also use with dammed up.
Additionally, I suspect that the use of the preposition here helps distinguish between it had been dammed and it had been damned. (Note the spelling.)
The verbs dam and damn are very similar, and are pronounced identically. (Although the past tense versions do have a subtle difference in pronunciation if you're listening for it.) But it would be quite unusual to say it had been damned up. So, if we see the preposition, it's an indicator that it's talking about a blockage rather than a curse. While context is likely to indicate the difference anyway, such an additional cue can't hurt.