I haven't seen any references to government requirements for those until after WWI, long after the Second Amendment or the Fourteenth Amendment were ratified.
It was not uncommon to have NSN (no serial number) guns, usually .22 rifles right up to the 1968 GCA. In my opinion, most manufacturers used serial numbers to track guns through the manufacturing process where considerable hand fitting was done. S&W revolvers also used assembly numbers. Early A5 shotguns have every damn thing stamped with full or partial serial numbers (stocks, barrels, bolt, screw heads…) Atleast my 1914 does. Early serial numbers also provided records of where guns were shipped, given that they could go to any hardware store or direct to customer.