Circuit design - usage of BOOT0 and a Hall effect sensor on STM32G431CBT6
The BOOT0 pin,by default, is used to go into factory bootloader if it is high when MCU is reset.
So basically, using BOOT0 pin for an input that can be in either state when MCU resets is bad decision.
Fortunately, the G431 default settings can be changed to disable BOOT0 pin to free it as standard GPIO, but then you can't use for entering into factory bootloader any more.
Details how to change the settings is found in MCU documentation, like datasheet, reference manual, factory bootloader appnotes, etc.