I seem to have the same problem. To expand on the error, here are some clues:
I got a similar error for a different package when I mistakenly installed gfortran for Intel based Macs. As soon as I reinstalled it for ARM based Macs, the problem was resolved.
I installed gfortran manually, because I previously installed it using homebrew, but that approach is apparently problematic.
This seems to give some background on the flat namespace error.
I haven't been able to solve the png error. I previously installed libpng through homebrew, and now tried to install it manually, but can't find a binary for it. It seems to support ARM based Macs.
Hope this helps someone on here to identify the problem, and possibly a solution!
A colleague resolved the issue today. He tried two things, the second worked for me, but the first might be good to start with.
In Terminal, install libpng using homebrew: brew install libpng. If you're not using homebrew, you can get it here. See whether this fixes the problem, if not, end all R sessions (if you hadn't before), install it again and try again.
I already had a brew installation of libpng. But one R package (farver) was locked for some reason. Apparently, R locks packages during installation and unlocks them afterwards. But if something goes wrong, the package may remain locked. Removing the locked package resolved the problem. To find the location of all packages run R.home() in R. The library folder in that folder hosts all installed packages. Within that folder, I removed the 00LOCK-farver folder using rm -rf 00LOCK-farver (in Terminal). Make sure to close all R sessions before you do so, otherwise you might interrupt other processes.