NextDNS and AdGuard DNS are just DNS providers that return filtered results for ad-related DNS queries. Their filter lists are public:
https://github.com/orgs/nextdns/repositories?type=all
https://github.com/AdguardTeam/AdGuardSDNSFilter
If you don't trust their DNS servers for whatever reason, you can simply add these entries to your hosts file to replicate their functionality locally.