This is because one of the defining characteristics of mammals is the presence of mammary glands, which produce milk to nourish their young.
The word "mammal" was first used in the 16th century, and it has been used consistently ever since to refer to this class of warm-blooded vertebrates.