You need to be trained to hear pitches. There are many more people with perfect pitch in societies that have tonal languages (I forget where I heard that). Western languages don’t use tones and so we never learn to pick them up, and that makes it difficult for us to hear them and produce them if we try to learn a tonal language later on.
The ear has to be trained. Sounds that are important are different in different cultures. If we don’t have to hear something, we don’t learn to hear it, and, in fact, often we can not hear it.
People can become tone deaf if they never attempt to do any kind of tonal music making. However, you can take a tone deaf person, and, with enough training and practice, teach them to carry a tune. Most folks just decide they are tone deaf and believe it is a hopeless state. It can’t ever change. So they never even try. But it’s a myth that tone deaf people can’t learn to carry a tune. One organization, Music for People, does teach the tone deaf how to sing. The main barrier, it appears, is the idea that hearing pitch is something innate and not something that can be learned. Once you get over that idea, it gets much easier to start learning to carry a tune.