That error means you didn't install the AFMotor library:
- Download https://github.com/adafruit/Adafruit-Motor-Shield-library/archive/1.0.0.zip
- (In the Arduino IDE) Sketch > Include Library > Add .ZIP Library > Select the downloaded file > Open
You should note the documentation says:
This library is old and deprecated - and the hardware disconinued years ago. V2 of the shield uses i2c only and works with anything that has I2C support (e.g. all arduinos) without endless incompatibilities and porting requirements!
-> Adafruit Motor/Stepper/Servo Shield for Arduino v2 Kit [v2.3] : ID 1438 : $19.95 : Adafruit Industries, Unique & fun DIY electronics and kits