After that the following command is executed: ‘ALTER SYSTEM SET max_connections = xxx;’
File postgresql.auto.conf is be created at ‘data’ directory, although this is expected in the same directory as the main postgresql.conf file.
The behavior described is intended.
For the reasons you note not every setting is a candidate to be set in this manner in every situation.
ALTER SYSTEM SET, like ALTER ROLE SET and ALTER DATABASE SET before it, persist its changes as data within the PGDATA directory. As far as I know nothing you access via SQL will modify (in a controlled manner) the three "files" that you can specify on the postgres command line. This seems generally sufficient if not desirable.