That is correct, you should not execute exactly that command line. Or perhaps more correctly, if you do use it as written, it will have no effect because the existence test for the file will fail.
I have not used Homebrew on an intel mac, but I have read in the documentation that it uses a different set of install directories than the arm64 version. You can see this with your “which gfortran” results. My working theory is that your Clang error is the result of some missing element in PATH or in some other missing environment variable. Those are kind of technical things that are a standard part of programming in a unix/posix environment, they are not specific to gfortran or MacOS. So I was not suggesting that you figure out those details at this time, rather I was hoping that someone here who does use Homebrew on intel MacOS 11.x or 12.x on might know the details and could help you out. Once you have things working, then you can go back and learn exactly what PATH and other environment variables do.
The difference in the way Homebrew works is that on arm64 machines, all of the files are placed in the /opt/homebrew directory. But on intel machines, the files are placed in /usr/local. FYI, on my intel macs, I have used a different package manager, Fink, for over 20 years. Fink places its files in the /opt/sw directory rather than in /usr/local, which is one reason why I selected it all that time. However, Fink does not yet support the arm64 hardware, so on that one machine I am using Homebrew instead of Fink. My experience so far is that Homebrew works well and is easy to use, and I would have said the same thing about fink up until three years ago when the arm64 macs were introduced.