Check the HKLM\System\CurrentControlSet\Control\PEFirmwareType registry value to see if the PC is booted to UEFI or BIOS mode. Note: you may need to run wpeutil UpdateBootInfo to make sure this value is present.

wpeutil UpdateBootInfo
for /f "tokens=2* delims= " %%A in ('reg query HKLM\System\CurrentControlSet\Control /v PEFirmwareType') DO SET Firmware=%%B
:: Note: delims is a TAB followed by a space.
if %Firmware%==0x1 echo The PC is booted in BIOS mode.
if %Firmware%==0x2 echo The PC is booted in UEFI mode.

If this is a frequent problem, you can remove the boot files for UEFI mode or BIOS mode to prevent the PC from booting in the wrong mode. If the PC firmware is set up to boot in the wrong mode, the media will immediately fail to boot, allowing you to immediately retry booting the PC into the correct mode.

Boot in UEFI mode: To prevent Windows PE from booting in BIOS mode, remove the bootmgr file on the root of the media.

Boot in BIOS mode: To prevent Windows PE from booting in UEFI mode, remove the efi folder on the root of the media.