How can u prevent melasma?

No. Melasma can be caused by birth control pills, pregnancy or be idiopathic (cause unknown). It more common in hispanics and asians. Avoidance of sun helps.
Awesome Sunscreen. If you are insanely good at sun protection, you can usually make your melasma significantly better. You have to be incredibly diligent about daily sunscreen usage though.