If the child and parent both do it voluntarily the government has no right to forbid it.
No, they do. The point about children’s rights and parental rights is not that children are some kind of quasi-property, but that children lack the capacity to make sound judgments for themselves. Objectively speaking, a child is simply not capable of making an adult decision about whether to buy 100 lbs of TNT and use it in a responsible manner. It doesn’t change things one bit if the parents say “Sure Johnny, it’s okay if you blow up the neighbor’s cow”. Parental permission doesn’t suddenly make it okay for a child to endanger himself or others. Parental decision-making power comes from the custodial obligation of parents, to make judgments in the interest of the child, because the child can’t soundly make those judgments himself. When a parent fails to make those sound judgments in the interest of the child, some other custodian of the child’s rights is necessary. Typically, a parent would be doing their job well enough – they would know where their child was, they would know about his money, who he was hanging around with, and they would prevent the child from buying explosives. Unfortunately, there are some crappy parents out there who will abdicate their responsibility. (Plus, there are escape-artist children who simply run away from home, who cannot be controlled by their parents). These “no-sale” laws cover that gap where the parent has shrugged off their responsibility.
I would say that the wishes of the parent are irrelevant per se. Parental wishes are generally presumed (and generally with good reason) to be in the best interests of the child. In most cases, such as decisions about clothing, hair style, vacations, pets, TV shows and video games, the consequences of error in judgment by the parent are really not so huge. Whereas, the potential consequences of selling explosives to a child (who then uses them) are quite significant, to the point that it cannot be in the interest of the child to allow them to buy explosives.
In fact, children do not have any right to buy anything, because they cannot be legally compelled to honor contracts (and a sale is legally binding agreement to exchange value for value). A fundamental principle of the concept “agreement” is that the parties have mental capacity to make the agreement. For this reason, a contract with an imbecile is also non-binding. So in order to allow children to enter into any sale, a special legal dispensation has to be made.
Because children are granted a special immunity from responsibility, due to their lack of mental capacity, in certain cases there has to be a curtailment of the right to free action. Indeed, the very idea that a man has the freedom to act however he wants is predicted on the “exception” while also respecting the rights of others. With children, that assumption of respect for rights cannot be made automatically, which is why children do not enjoy the same freedom as adults. An adult may rightly purchase and use explosives based on the fact that he will be held responsible for the consequences of his actions. A child will not be held responsible for the consequences of his actions, which means that he must be otherwise prevented from initiating force against others, namely by preventing him from possessing dangerous weapons. The restriction on sale of explosives is one way of balancing the child’s lack of responsibility against the danger that his actions might pose.