Naturally the castle defends the river but the river also defends the castle too. Also w.r.t Beaumaris, the moat water might be stagnant now but it was originally connected to the castle and it has in more recent years become land locked. Here is a quote from the site...

The first line of defense was provided by a water-filled moat, some 18ft wide. At the southern end was a tidal dock for shipping, where vessels of 40 tons laden weight could sail right up to the main gate.
These were examples of castles with water around them. There are many which did not have water and had just a ditch whether natural - like Tintagel or artificial (at least on some sides) like Harlech, or Dover.

I cant think of a castle which has water around it which is not connected to the sea or a river and made from an artificial ditch. That was the point I was trying to put forward. There must be some but I think they are more the minority. In order to have standing water with no source you would be on naturally boggy ground which is how Beaumaris continues to keep its water but its not often that a castle is sited on such ground - for a second reason that would imply low lands when castles are usually sited on hills.

Yes, cannons changed everything. Castles changed considerably over the period as experience and technology improved but cannons brought the end of traditional castles. They adapted a bit to the cannon with their soft sloping walls etc but it was short lived.