[1] The name comes from the nut's resemblance to the crenellated parapet of a medieval castle.
Castellated nuts are formed with a round section at the top where the slots are located.
Both castellated and slotted nuts are designed to use a pin (usually a split pin) that fits through the slots and through a hole in the screw to which the nut is attached.
The nut is then secured with a split pin/cotter pin, R-clip or safety wire.
[1] Castellated nuts are used in low-torque applications, such as holding a wheel bearing in place.