Error in compiling esp32 in arduino ide

Everything works exactly as you have programmed it.
Though if this is something different than you expected you don't yet understand your own program.

You are printing the bytes received on the software-serial-interface to the serial-monitor
your

Serial.print(Serial2.read());

53 is the ASCII-Code of character "5"
and
48 is the ASCII-Code of character "0"

I think if you assign the received character to a variable of type char and then do a serial.print with that char it should do what you want.

You should post code by using code-tags
There is an automatic function for doing this in the Arduino-IDE
just three steps

  1. press Ctrl-T for autoformatting your code
  2. do a rightclick with the mouse and choose "copy for forum"
  3. paste clipboard into write-window of a posting

so something like

char myRcvChar;

and then

myRcvChar = Serial2.read();
Serial.print(myRcvChar);

will do the job.

Work through this tutorial

best regards Stefan