I have read several explanations for this: e.g., sons and daughters under the age of six were considered asexual and dresses provided ease of movement.
See images of two paintings from Skinners American Furniture and Decorative Arts auctions.
This one is described as “ Portrait of Two Children Playing at the Table with their Pet Pugs” depicting “… probably a boy and a girl, wearing identical pink off-the-shoulder dresses with black trim..." Notice the boy on the left pulling a toy soldier on horseback and the girl on the right holding a rose.
This other one is a portrait of “Young Harry Herbert Keith (1851-1925) of Newton, Massachusetts”. He is in curls wearing a red and white plaid dress and black hat.
DID YOU KNOW that associating pink and blue to genders is a 20th century phenomenon, and that initially pink was associated with boys and blue with girls? Pink was considered appropriate for boys because that color is related to red – a more masculine color. Blue was reserved for girls for being a more dainty color, relating to the Virgin Mary. This societal norm was inverted in mid-20th century.