I'm not sure if this is how the specific ones being talked about might be working, but a simplified way of doing it would be that when APP A is installed it connects to a server and tells it that it has been installed with UNIQUE DEVICE ID, that way APP B can connect to the server and see if APP A has been installed on UNIQUE DEVICE ID. You can imagine ways to do the same with viewing ads etc.