Yes, castles that are located near lakes will have moats but not all castles will be located near lakes. Those that are located in the mountains may not have moats. The purpose of a moat is to make sure that the castle will be defended from an attack. Moats are known to be very effective in trying to ward off different people from entering the castle.
There are some moats that come with bodies of water wherein alligators are available. Some people may assume that all moats are like this, but actually, there are some moats that almost do not have water. It will just be harder for people who would like to enter the castle unattended. Aside from the moats, castles have walls that will make sure that it will not be easy for people to enter.