These can happen due to food habits, weak tooth structure (such as enamel dentine), improper brushing, excessive amount of fluoride taking, genetically inherited issues, general enamel hypoplasia etc. The less immunity is not the issue, once enamel is already made it cannot be developed again and tooth structure develops within the jaw bone within 15 year's old, as a result as immune treatment can't effect your teeth structure.
If immunity falls then gum problems, ulcer of the mucus membrane etc develops but tooth structure can't be compromised so it's very unlikely of less immunity to cause cavities.
Next Steps
Maintain oral hygiene such as:
-Proper Brushing
-Flossing
-Warm saline water oral rinse
-Scalling
-Filling of the cavities
Health Tips
If the cavities are exposed then RCT and then Crown is required.