why this is happening, is it about he battery being depleted?
A laptop generally has two types of battery.
The rechargeable powerpack to power the machine when disconnected from mains.
If these batteries are flat, the BIOS/UEFI shouldn't be affected.
The second type is a small internal non-rechargeable button type battery which connects directly to the motherboard and maintains the CMOS memory when the unit is not switched on. The CMOS memory holds the setup parameters used by BIOS/UEFI and needs very little energy so the button cells can last for years.
But even so, at some point the button cell will be unable to reliably support the CMOS memory. This is exacerbated if the unit has no power for an extended period.
This is likely why your machines presented with the BIOS screen when powered up for the first time out of storage.
how to avoid this..?
If the machine is in daily use, an aging button cell might have enough energy to keep the CMOS going. But it may not be practical to do this. Like any failing battery the proper fix is to replace them.
For a laptop, the cell is typically packaged with pre-made leads and a plug to connect it to the motherboard and still fit inside the laptop case. You need the right package of battery/leads/plug specific to your hardware and to be able to open up the case.
If you can get the cells and are able to get inside the cases, routinely replacing the original button cells with decent quality new parts when re-furbishing the laptops should give many more years of service. For desktops this is simpler as access is easier and usually there is a battery holder on the motherboard which accepts a standard battery.
the steps I can do if the bios shows up again when it’s started up?
Keeping a note of the steps required to enter the BIOS/UEFI set up mode, how to return to default settings and the changes from default that need to be made on each model is good practice. If you a fit new battery, the CMOS will be defaulted so noting the steps to get it working again should be done then. May turn out to be useful even if the battery never gets drained as the settings may need to be reset if someone interferes.