Old covenant law required that firstborn sons be redeemed from priestly service; it did not require them to be brought to the temple. The sacrifices for purification were for the mother and not for the child. Given the fact that the mother had to go to the temple, and that she was nursing the child, we can assume that most children would have accompanied their parents.
27 And he came in the Spirit into the temple, and when the parents brought in the child Jesus, to do for him according to the custom of the Law,