The dnf list command will list both installed and available packages in the repositories you have installed. The repositories you have installed will be listed at the beginning of the output. It is very common to install the EPEL (Extra Packages for Enterprise Linux) repository.
~]$ dnf list | head
* base: centos.mirrors.tds.net
* centos-sclo-rh: mirror.den01.meanservers.net
* centos-sclo-sclo: mirror.den01.meanservers.net
* epel: mirror.team-cymru.com
* extras: centos.mirrors.tds.net
* updates: mirror.genesishosting.com
Something like this will be returned, which shows the package name, version, and repository the package is in.
ansible.noarch 2.9.18-1.el7 epel
openssh-server.x86_64 2.4.6-45.el7.centos.4 base
openssl.x86_64 2.4.6-45.el7.centos.4 base
krb5.x86_64 2.4.6-45.el7.centos.4 updates
nginx.x86_64 2.4.6-45.el7.centos.4 base
httpd.x86_64 2.4.6-45.el7.centos.4 base
The dnf list installed command can also be used to list only installed packages.
dnf list installed | grep -i httpd
. . .
Installed Packages
httpd.x86_64 2.4.6-45.el7.centos.4 @updates