It a mongolian spot a medical condition? Why do some babies get them?

No. These are birthmarks, usually on the lower back and buttocks. Most often seen in people of color.The cause is totally unknown as is the reason they occur.They are cosmetic only with no known problems or complications.
Random genetic effec. Mongolian spots or patches are islands of skin with a tendency to form more pigment than the surrounding skin. They often have a bluish tint, occur mostly in the mid-line of the lower back but can occur in other areas. There is an ethnic (genetic) component, occurring more often in asian & darker skin colored groups. They are a curiosity, not a disease.