No one really knows. Nobody really knows what causes birthmarks. Vascular birthmarks are not hereditary but thought to be caused by overdevelopment or overgrowth of blood vessels. Many theories for different types of birthmarks: some may be hereditary (most are not), some caused by random genetic mutations, overgrowth of pigmented cells called melanocytes, abnormal collection or overgrowth of blood vessels.
Random luck. In most cases. Occasionally, there are birthmarks that are associated with genetic syndromes, but these are less common.