Sure, there a few reasons to do it like this.
First, my impression is that you still have the right to send your children to a private school where this won't be enforced. So it's not a law, it's a policy passed at the national level for the public schools, which are organized from the national level.
Secondly, passing the law at the national level deals with the situation where a school gets "bullied" into not passing the policy to begin with. For example, parents might prioritize being able to coordinate pickups in real-time over their children's education (I'm not implying bad intent: they just might not recognize the negative impact of their children's mobile use during class time) and thus pressure a school to not ban mobile use during class time.
Personally I think your own definitions of what are reasonable and what are not are skewed. You think it's over the line to claim that "children are not too often, or even at all, in front of a screen before the age of seven"??? What could a five or six year old possibly be doing on a smart phone aside from watching videos and playing games? Why do middle schoolers need access to their phones during lunch - what do they gain from it?
I'm not French though, so someone will have to double check me on the claim that this is actually a national policy for public schools rather than an actual law.