As a baby listens to her parents talk, her brain somehow sorts the sounds into specific sound categories. This happens even though mom and dad say the word "hello," slightly differently because of accents or pitch. Despite those subtle differences, a baby's brain absorbs the sounds and classifies them as equivalent.
This kind of learning is quite different from the way researchers study adults learning a second language. Foreign language learning is often studied in a controlled setting through trial and error or multiple-choice options with reward-based results.