To avoid doing that in the first place, make sure you choose the right place to do your manicure and pedicure and give yourself enough time for the nail polish to dry.
When the stain is on your clothes:
Put a cloth on the stain and apply a sufficient amount of nail polish remover on the cloth, locating the stain. Wash as usual. If you don’t achieve a satisfactory result, consult a dry cleaner for help.
When the stain is on your carpet:
Use a cloth and some nail polish remover as well, then rinse with cold water and apply carpet shampoo.
In every case, always read the manufacturer instructions if there are any, before you do anything. Then proceed with a small test patch. If any doubt, consult a professional cleaner.