Analog input causes program to fail

Do a dummy read to give the ADC (which is multiplexed for all 6 lines) some time to adjust, or do some averaging over multiple measurements.

furthermore the map() function eases the mapping of the potvalue to LED range.

applied to your code (not tested to compile )

int potPin = A1; // max pin pot
int potValue = 0;
int sensorPin = A0;    // select the input pin for the potentiometer
int sensorValue = 0;  
int ledPin = 2;      // select the pin for the LED
int maxPin = 0;

void setup()
{
  Serial.begin(115200);  // why only 9600
  pinMode(sensorPin, INPUT);
  pinMode(potPin, INPUT);
  pinMode(ledPin, OUTPUT); 

  for (int pin=2; pin<10; pin++) pinMode(pin, OUTPUT);
}

void loop () 
{
  sensorValue = 0;
  for (int i=0; i < 16; i++) sensorValue += analogRead(sensorPin);  
  sensorValue /= 16;
  Serial.print("sensorValue = ");
  Serial.println(sensorValue );

  potValue = 0;
  for (int i=0; i < 16; i++) potValue += analogRead(potPin);  
  potValue /= 16;
  Serial.print("Potvalue = ");
  Serial.println(potValue);
     
  digitalWrite(ledPin, HIGH);  
  delay(sensorValue);
         
  digitalWrite(ledPin, LOW);   
  delay(sensorValue);  // missed this one?
   
  ledPin++;
  if (ledPin == maxPin) ledPin = 2;
  
  maxpin = map(potValue, 0, 1023, 2, 10);  // as the multiple if then elses are in fact a linear function
}

finally some remarks on the original code

if ((potValue <= 0) is a semantic bug as potvalue can never be smaller than 0 from the ADC reading

furthermore the multiple if then could be simplified to nested ... if then else if ... (

  if (potValue <= 126)) {maxPin = 3; } 
  else if (potValue <= 253)) {maxPin = 4;}
  else if (potValue <= 380)) {maxPin = 5;}
  else if (potValue <= 507)) {maxPin = 6;}  
  else if (potValue <= 634)) {maxPin = 7;}
  else if (potValue <= 761)) {maxPin = 8;} 
  else if (potValue <= 888)) {maxPin = 9;} 
  else {maxPin = 10;}

This is more tuneable than the map() function above as you can decide where the 'borders' are