Every time a process on RHEL needs to reach a hostname (server1.lab, db.example.com), the resolver consults two ordered sources: the static hosts file (/etc/hosts) and the DNS servers configured by NetworkManager. The order is governed by /etc/nsswitch.conf — by default, hosts: files dns, meaning /etc/hosts is checked first and DNS is the fallback.
/etc/hosts is a tiny key-value file you edit directly: one IP address followed by one or more names per line. DNS configuration, on the other hand, is owned by NetworkManager — /etc/resolv.conf is regenerated from the active connection's ipv4.dns settings. Editing resolv.conf by hand on a NetworkManager-managed system is wasted effort: NM will overwrite it.
The system's own name comes from /etc/hostname, but you change it with hostnamectl set-hostname so both the kernel and the file stay in sync.