I encountered this problem setting up my Pi 4 with the 2021-10-30 version of Bullseye Lite. The howto I followed had a wpa_supplicant.conf file that started with:
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
and when I hooked up via Ethernet, rfkill complained that the country code was invalid. I used raspi-config to "update" it with the same value, and the first three lines came out as:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
The WiFi started working correctly.
When I used the changed sequence on my Pi Zero W, it worked correctly the first time.
Looks like some code in the startup software is fussy about the order in which it finds parameters.
/etc/profile.d/wifi-check.sh
sudo rfkill unblock wifi
(thanks @Kingsley) from the UART interface.