How does moat work?
You can place moat from the extra defences tab of the Castle view in the Village tab. Moat will cost 20 gold per tile to place. You can left-click and drag to place large sections of moat at a time. Also note that, as with walls, you cannot completely surround your castle in moat, but can use gatehouses to fully enclose your castle. When enemy troops reach the moat, they will need to dig it up in order to pass.