Unbound, dnsmasq and similar tools often listen on a port like 5335 behind Pi-hole or AdGuard Home. dig has to be told about that.
dig -p 5335 @127.0.0.1 example.com +short
-p sets the port for the query, and @127.0.0.1 picks the server. Without it, dig talks to port 53 and you end up testing the wrong service. This is a quick way to compare what the front resolver returns and what the upstream behind it returns. Use ss -lunp first if you do not know which port the daemon uses.
Further reading: dig manual page
Going deeper: Guide: dig for beginners, look up DNS records and read the answer