Is the art made for anime openings made first or are the created vocals done first? Sometimes the song matches perfectly with the opening like the beginning of Little Witch Academia, so I was wondering if the art for the opening was done then the song was made to match the art, or if the song was created, and the artists made the opening based off the song?
In this particular case, it seems the song was recorded first.

Generally, it differs. Traditionally, voice acting and drawing were independent of each other, both being dependent on the story board.

Then one movie came out which had the voice acting done first and then after that the drawing, so that the animated lips would match the (Japanese) text. This was a huge revolution at the time. I believe that film was Ghost in the Shell, although I cannot find a reference to back up that claim.

Having the drawing matching the voice acting means more work, means more expensive. Additionally, since voice acting needs to be done first, both can't work parallel the whole time, so production time is longer, which also means more expensive. Because not doing production in that strict order is cheaper, you usually see it employed in most anime, except for special occasions like openings, which can be reused multiple times.