Tour guides of historical sites are often completely or even willfully wrong about facts like this, but in a sense almost all castles exist to exert control over nearby resources so they're probably right.
It's probably both. Rivers are convenient for transport, which means raiders can also target them since so much valuable stuff is transported that way. A castle is a sensible way (in those times) to put a protective force in place against the raiders. However, the castle and the people protecting river traffic need money, so of course that comes from tolls.
It's no different than any "protection racket" or police force: the money has to come from somewhere to offer protection, so some form of tax is normally used.