This Google Script will help you download your email messages from Gmail to your Google Drive in the EML format.
Nice little snippet from Amit Agarwal for generating .eml files from Gmail messages using Google Apps Script. The post has all the code you need for this.
Source: Download Gmail Messages as EML Files in Google Drive – Digital Inspiration
Member of Google Developers Experts Program for Google Workspace (Google Apps Script) and interested in supporting Google Workspace Devs.