My child hits herself

Recently my baby girl has been hitting herself in the head with her hands. Also, when I tell her be nice she hits her hand. Anyone know why she would be doing this or how to get it to stop?