When you place the dam the water does, for a time, flood the road and the surrounding area. You can't just build a wall and expect the water to stop right away. There's more water coming from upstream and so it pushes up and over and around the dam.
After a period of time the dam will start operating and continue the flow of water. I believe the game will also disable a few water spawners to bring water levels back to normal.