The "custom nameservers" that some hosts allow you to configure for your domain are usually just an alias for the hosts primary nameservers, pointing to the same IP address. As @Stephen pointed out in comments, this requires you to manually configure glue records that point to this IP address (although the host may do this for you, if the registrar and host are one and the same).
The main reason for custom nameservers is to obfuscate the true DNS provider / host. This is a "white label" solution, primarily aimed at resellers that want to "hide" the true host they are reselling on behalf off, to make it look as if they are really the provider. However, this is only a superficial layer of obscurity as anyone can do a reverse lookup on the IP address to find the real provider.
An additional caveat with using "custom nameservers" of this nature is that if the IP address of the host's nameservers should ever change then you will need to manually update the glue records.
When other domain names use my custom name servers, how do I redirect their visitors to a specific page of my website
As @Patrick mentioned in comments, these "custom nameservers" have nothing to do with redirection. The NAMESERVER ("custom" or not) simply informs the requesting user-agent of the IP address to use in sending the request. This doesn't necessarily have anything to do with your domain name or your website.
and also remember the source domain names by using the query string?
In order for
randomdomainname.example to map to your hosting account (ie.
example.com) you need additional directives (eg.
ServerAlias) in the server config so that your account will respond to requests for this domain. In cPanel (for example) this is an "Addon domain" or "Domain Alias".
Once you've created the Addon domain in your account then you can examine the
Host HTTP request header (
$_SREVER['HTTP_HOST'] in PHP) to determine which host has been requested (no need to use a query string or create a redirect).
randomdomainname.example points to an entirely different account on the server (remember the NAMESERVER only tells you which server the account resides on) then any redirect back to
example.com needs to be created on that other account in the same way you'd create any redirect (by returning a 3xx status and a