Don’t want to upset anyone but I’m curious

So I myself have a little girl she is 1. I’m black her father is mixed I want to stay that before anyone say I’m being sensitive to anyone. So I see mothers both black and white putting bonnets on they 8,9 month babies and some 1 year olds also for bed time. I don’t understand I was curious is it good for the baby hair or something. All I do to my little one hair is use olive oil and comb it with my fingers. I’ve just been so curious isn’t it unsafe if it comes off while baby sleep or slide down the face, I know mine come off some nights when I sleep and I don’t move in my sleep much. I’ve asked friends but they don’t know either and no I’m not super young and confused I’m 33 this my first. With my nieces we never used bonnets and they have beautiful hair, just used olive oil till they was old enough for anything else. I hope I don’t upset or touch a wrong feelings with someone but I’m honestly curious. I even asker my pediatrician would it help with hair growth, he said it’s unsafe for little ones to nap or sleep in them.