Why /usr/local/bin is showing as a file in mac?
This is definitively not how it should be, but without a lot of additional analysis it's impossible to figure out what else is wrong. So to be on the safe said, I would

create two good, verified backups
do a clean install (not an upgrade)
restore Applications and user directories from Time Machine
install Homebrew from scratch.