A charity has been given a £5 million grant to help fund a project that prevents women's imprisonment and maternal separation.