My cousin was in a situation like this. She got pregnant with an unsteady boyfriend's baby. She got a lawyer, explained things, and won.
I think you'll do the same. The father should not share custody, at least not for five years.
The cop probably was just checking your friend's license. Sometimes people look to young to drive.
However, for the other stuff, I really suggest that you get a lawyer if you can afford one. If not, plead "not guilty" at court and get a public defender. This is a very complicated case.
Get an attorney immediately. You can petition to have custody over her if she is not yet 18.
But, if you really don't want her in her house, you can petition to get her out of her mother's house and get help for her if possible.
Your husband could possibly go to jail if he didn't have his record expunged.
You got a count of "child neglect" because keeping illegal substances in your house is selfish of your own needs and neglectful of the child in the cop's eyes.
This was not an illegal search.