What do you expect from analogWrite() on the XIAO ESP32C3?
It cannot provide analog voltage output because it does not have a built-in DAC.
For PWM output, please see the following instead of analogWrite().
//\Arduino15\packages\esp32\hardware\esp32\2.0.6\cores\esp32\esp32-hal-ledc.c and .h
edit:
I have confirmed that the following code works, needed delay() in the loop. I do not know why.
int pwm = 0;
void setup() {
Serial.begin(115200);
pinMode(D10, OUTPUT);
pinMode(D1, INPUT_PULLUP);
}
void loop() {
pwm = map(digitalRead(D1), 0, 1, 0, 255);
Serial.println(pwm);
analogWrite(D10, pwm);
delay(100); // needed
}