This smells like the classic bootloader vs DOS USB handoff problem. The firmware on the Pi handles the keyboard fine during boot because it drives USB itself, but once DOS loads it has to talk to the USB chip through its own drivers, and those are a lot pickier.
First thing I would try is moving the keyboard to one of the black USB 2.0 ports, not the blue ones. On the Pi 4 the two port types go through different hardware, and I found on my setup that the DOS USB driver only wanted to play with the 2.0 side. Cheap membrane keyboards generally work best here too, since they speak the older simple HID style the driver expects, so your membrane one is the better test candidate. Second thing to poke at is the config. If you pop the SD card into another computer you should be able to see the DOS partition and open the startup files in a plain text editor. There should be a line that loads the USB or HID driver at boot. Check it is not commented out or missing, and check the file name matches exactly what is on the card, capitals and all. DOS is unforgiving about that. Also worth doing: pull the config.txt off the card and have a look, since a setting in there can affect how USB is handed over to the OS. The repo usually has an issues page or discussion tab, and a search for 'keyboard not working' on your exact release will often turn up someone who hit the same wall, sometimes with a one line fix. One more long shot, but try the mouse on its own in a different port after the keyboard test. If neither HID device works in any port but both work in the bootloader, it points to the driver never loading rather than a compatibility issue with specific keyboards, which would make the config.sys check the real culprit.
If all that fails, rebuilding from source is actually less scary than it sounds, but the prebuilt image plus a config fix is usually enought.