The only free and comprehensive online etymological dictionary of the Spanish language
mamá, mama f. (Noun) "mommy"
11th cent. From Latin mamma "mother," but also "breast." Variant mamá is an 18th cent. stress shift under French influence. From Proto-Italic *mamma 'id.' From Proto-Indo-European *mam(m)a 'id.' A rare example of a putative *a in Proto-Indo-European, probably due to the ease of /ma/ in children's speech.
Portuguese mama, French maman, Italian mamma, Aromanian mamã, Romanian mamă, Sardinian mama
Old Irish muimme "nurse," "fosterparent," Middle Welsh mam "mother," Middle Breton mam 'id.,' Old Cornish mam 'id.'
Albanian mëmë "mother"
Russian máma "mother," Lithuanian mamà 'id.,' Latvian mãma 'id.'
Ancient Greek μάμμα (mámma) "mother"
Armenian mam "grandmother"
Sanskrit māma- "uncle," Persian mām "mother"

Responsibility as caretaker of a child may not have always belonged to the biological mother, but rather a foster parent. Thus, this word was used for the closely-knit parent, not the official 'mother,' which explains the meaning of "uncle" in Sanskrit and "nurse" in Old Irish. Consider the comment of Matasović (2014) on the Irish example: "The fact that the nursery word *mammā usually does not denote the biological mother is explained by the Celtic custom of fosterage (children are raised by foster-parents, with whom they develop an intimate relationship)." Further consider the comments by Benveniste under madre.