all mammals have mammary glands regardless of their gender, yet "while the glands are generally less well developed and nonfunctional in males, the degree of underdevelopment varies among species."
In most cases, men simply don't produce enough prolactin for their bodies to lactate. Prolactin is a hormone that is produced by the pituitary gland which is located at the base of the brain. It helps to produce milk in pregnant and breastfeeding women.