The buttons are "stitched" on by machine, hastily, without proper fastening-off. If the manufacturers give you a bit of spare matching thread, you'd do best to reinforce the stitching before you wear stuff.
Years ago, it used to be quite common for the buttons on mens shirts to fall off. Then manufacturers started providing a couple of spare buttons stitched to the bottom of each shirt. Since they started doing this, I've never had any button come loose on any of my shirts, and so I've never had to use the spare ones supplied!
I haven't had a button fall off a garment I wear for many, many years. My son regularly pings the button off his school trousers though and he isn't in any way a fat kid (6ft tall and 10st).