If you install homebrew as per their instructions without any crap preceding their installation instructions, it will detect whether you are on an Intel or Apple Silicon platform, perform its installation accordingly (they are different), and detect that there is no Apple Command Line tools and relevant compiler (clang) installed and will do that for you. If you review the mingw-w64 opensource site, it offers a runtime environment for GCC on Windows, not macOS, and that is the root cause of that bad cpu type error message. Windows application binaries do not run in macOS.
Although brew can install GCC 12.* on macOS, you would have far less confusion and arguably better code using Apple's clang/clang++ compiler than GCC. Too many people over the last few years have confused or attempted to mix these compiler suites header and library files causing no small grief. That GCC build in homebrew may take an hour.
Apple's clang (or Swift) compiler is the drug of choice on macOS and can cross-compile for Intel, Apple Silicon, and using lipo(1) one can even produce a Universal2 binary with both architectures in it. You will receive little to no support here for third-party package managers, and alternative compiler suites that you install.