Why do babies cry and look scared randomly when they are sleeping?

My baby randomly starts crying like a small puppy. He makes sounds like he’s scared or sad. Is it because my baby is having nightmares?