I understand what you want and that is what the code provides for. When the right hand limit switch is reached the input to its Arduino pin is no longer LOW and the program exits the first while loop. The state of the right hand switch no longer matters as it is not being checked. The same thing happens going from right to left.
Comment out the second while loop (3 lines). Does the carriage move to the end and stop ?
Put the second while loop back in place and comment out the first one (3 lines). Does the carriage move to the other end and stop ?
You say in an earlier post that when pressed the switches go to 6V. This sounds suspicious. Where are you measuring the 6V ?
Can you please draw a simple diagram to show the circuit including the switch, ground the Arduino power pins, resistor and switch ?