analogRead

How can the analogRead() function return a value greater than 1023?

The range is 0 to 1023
http://arduino.cc/en/Reference/AnalogRead

You can scale the value you do read. Most people use the map() function.

here is some pseudocode showing what math is involved:

int A = analogRead( myAnalogPin ); // read the pin
long S = (long) A * 10000UL / 1023UL; // scale the pin 0 to 1023 up to 0 to 10000
A = (int) S; // and back into A

Note that integer multiply or divide is much slower than integer add or subtract, but compared to floating point they are fast.

I get a value greater than 1023 from the analogRead function itshelf. The last value I got was 17286.

Show us your sketch.