It sounds like you're just not familiar with how CPS works, no offense. If a child is being subjected to an unsafe situation they can legally remove a child, whether the conduct rises to the level of illegal conduct or not.
Medical professionals are mandatory reporters (I'm not sure if that's the same legal term in NY, my experiences with CPS have been with several other states). That means they are legally required to notify CPS if they see or THINK they see evidence of abuse. Allegations must be investigated before being acted upon.
I can certainly see why you don't like the fact that the hospital tested the baby for marijuana but if it means they need to modify treatment of the baby they absolutely can do that. Testing the mother may be different, like I said I don't have experience with the NY system.
In short it sounds like you are just not familiar with the standard processes of CPS and are actively interpreting everything in a negative way.
No they can't, but CPS can remove a child for all kinds of abuse that doesn't rise to the level of illegality, it's like that in every state in the US.