Gates act as a way to stop your animals from leaving a certain area. They take 10 normal wood which you get from trees. You need 2 of any fence placed down with one space between them. Then you put the gate between them. You right click to open and close it.
NOTE: Animals can leave if the gate is open.