Raspberry Pi loses network connection

Have you tried another power adapter and cable?
Raspi's can crash or even corrupt storage (SD card etc) if the power isnt sufficient.
See also below:

https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#power-supply-warnings

You could also check the systemd journals for errors/warnings etc for the current --boot:

sudo journalctl --full --no-hostname --catalog --priority warning --boot

Or two boots back (-2):

sudo journalctl --full --no-hostname --catalog --priority warning --boot -2

List all boots:

sudo journalctl --list-boots