The above events are different in the anime; when two police officers find Mayu in the shack, she tries to run from them, but she bumps into Kouta, Yuka and Nyu who have spent all day searching for her.
When Kouta and Yuka offer to become Mayu's guardians, her mother officially transfers Mayu into their care without a second thought.