The basic explanation is based on a combination of infant anatomical development and parental expectation. Infants don't initially know how to control their velum, so everything is nasalized. Also, when breastfeeding a child has to lower the velum (to breath). This weights the probabilities in favor of the word for "mother" having a nasal. They initially can best control their lips and jaws (lips are vastly more important for breastfeeding that the tongue is, so naturally lip-control is really important).
Random babbling from an infant is most likely to generate syllables like [ma] and then [ba], as compared to [na], [da]. Parental expectation comes in because the most likely parental response to a child randomly babbling something language-like is "They're referring to me!". The tendency to associate [ma] with mothers and [ba] with fathers is founded on the fact that infants have more frequent interactions with mothers than with fathers, and [ma] is the most likely candidate for a "first recurrent syllable".
The standard words in languages were conventionalized a really long time ago, hence "mother" and "father" don't particularly resemble "ma" and "ba", unless you know a bit more about Indo-European historical linguistics. Even epithets like "mama", "papa" (or "daddy") are conventionalized though subject to a more variation than the standard lexical items. See for example the relative uniformity of "mama" for mothers, but more variation for fathers, being "dada" or "baba" (or voicing variants tata, papa).
One of the most stable consonants in language is [m], so there is no common path whereby [ma] becomes something else. But [ba] easily changes to [pa], from which [fa].
So in summary, there are natural physical reasons for utter [ma] correlated with the presence of mother, and [ba] correlated with the presence of father; parents then interpret there phonations as referential, which encourages the conventionalization or [mama] as a word meaning "mother", because parents believe that the child its referring to them.