I am a 13 year old boy and I wear diapers (own choice)
It depends what the issue is. Some children (and adults) have a condition called, "Enuresis". This condition is typically caused by physical reasons. Some of these reasons are hormonal, lack of bladder sphincter development, drinking too much before bed, etc. Other reasons may stem from (but not necessarily proven) traumatic experiences as a child. Finally, some children (and adults) simply like wearing diapers. Regardless if the condition is medical or psychological, there needs to be honest and open conversation. Obviously, if the condition is medical, consult your physician as soon as possible. No matter what the situation, it is essential not to "shame" or embarrass your child. Whether medical or psychological, it is hopeful your child will "outgrow" the condition. There are medicines and alarms that can be used (medicines for hormonal/physical conditions) and alarms for "conditioning" your child.
Some may have to wear them at night because of medical conditions that can cause them to not awaken when they have to use the bathroom.