Why my arduino code needs to re-upload or reset the arduino to function the code again

HINT: SoftwareSerial is different to a UART (hardware serial).

You really don’t want to use SoftwareSerial unless you know why and what the shortcomings are.