If it is sunny then it is good with a sun hat giving a good sunprotection. A sun hat is good for both newborns and small children.
A small child lying in the trolley does not necessarily need a hat, but if it is cool or windy then a helmet hat or a thin hat can be good. Touch the baby to see if the child feels cold or sweaty.
A cap is good to shield the sun so you do not get dazzled. It's also fun with all varieties, and motives available. It can also help against sunstroke. In short, a cool alternative to sun hat.
A children's hat is important to protect against the cold and wind. It must also be nice and comfortable. Winter hats for children may well have some fun designs from the child's favorite movie or favorite game. Then it becomes more fun when the child gets the cap.