'Display' does not name a type

I've been trying to put 2 separate animations on 2 oleds using 1 arduino mega, but i keep getting error message "'Display2' does not name a type".
The code was working with one animation on 1 oled but when i tried to add the code for the second animation and oled i get this message.
Ive changed the i2c address on the oled and the code but i don't know what to fix in my code to solve this problem.

Heres my code code

You have a bunch of code that's outside of a function, thus the error.

A very helpful troubleshooting tool is the Auto Format feature (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor). If you do an Auto Format and then compare the resulting indentation to your intended program structure, it will quickly point you to where there is a missing or extra brace.

Another useful feature of the Arduino IDE/Arduino Web Editor is that when you place the cursor next to one bracket, it puts a box around the matching bracket. In the Arduino IDE, if the cursor is next to the closing bracket and the opening bracket is off the screen then it will show the opening bracket line in a tool tip after a short delay.

It seems that I posted a Horse animation back in 2016

It looks a lot simpler than your code. Especially when the data is kept in a separate file.
You should be able to adapt it for two screens quite easily:

/*
 *  Image of Horse Gallping originally photograph by Eadweard Muybridge. For more information
 *  about Eadweard Muybridge go to: https://en.wikipedia.org/wiki/Eadweard_Muybridge
 *  Image: http://animationresources.org/wp-content/uploads/2015/05/Muybridge_race_horse_gallop.jpg
 *  Software to convert images to 128x64 at: http://www.ablab.in/image2glcd-software/
 *
 *  Minimal sketch to run animation with 128x64 I2C SSD1306. Written by Greg Stievenart with no
 *  claim to or any information provided in this code.
 */

#include <Wire.h>                     // requried to run I2C SSD1306
#include <SPI.h>                      // requried to run SPI SSD1306
#include <Adafruit_GFX.h>             // https://github.com/adafruit/Adafruit-GFX-Library
#include <Adafruit_SSD1306.h>         // https://github.com/adafruit/Adafruit_SSD1306

#define OLED_CLK 13
#define OLED_MOSI 11
#define OLED_RESET 8
#define OLED_DC 9
#define OLED_CS 10

//Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); // I use SPI
Adafruit_SSD1306 display1(128, 64, &Wire);  //Adafruit have changed constructor style
Adafruit_SSD1306 display2(128, 64, &Wire);

extern const uint8_t *horses[];       // private tables and public pointer array in separate file

int framecount = 0;

void setup() {

    display1.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // required to run SSD1306
    display1.clearDisplay();
    display2.begin(SSD1306_SWITCHCAPVCC, 0x3D);  // required to run SSD1306
    display2.clearDisplay();
}

void loop() 
{
    if (++framecount > 14) framecount = 0;
    display1.fillRect(0, 0, 128, 64, WHITE);
    display1.drawBitmap(0, 0, horses[framecount], 128, 64, BLACK);
    display1.display();
    display2.fillRect(0, 0, 128, 64, WHITE);
    display2.drawBitmap(0, 0, horses[framecount], 128, 64, BLACK);
    display2.display();
}

Untested. But it looks fairly straightforward.

Incidentally, there is a faster way to do the animations. And a faster way to handle 2 screens.

David.