We have precedence in
restricting sales of certain substances to minors. A physical hand off has to take place in a physical place where a government issued ID can be checked for age verification. If you get caught breaking this law, you can lose your license to sell these things (and likely go bankrupt cause these things make a ton of money), because the government controls that, too.
This is in no way the same thing as policing "creating algorithms". We don't/can't go after Labatt for "creating beer" (it was tried...). I agree, writing laws is challenging, but even professional law makers can't get it right, not in the sense that they aren't skillful enough to get it right, but in the sense that it is not possible. We're seeing this with Porn Hub in certain US states. Local laws are just not effective in enforcing a multinational Internet service. To get back to the original point, this is why you might want to try something other than "having the government pass laws about restricting social media for youth under a certain age".