I'm pretty sure iOS has the website issue a request to open X app w/an argument, so in this case it's Twitter making a request to open their app if installed.
Not sure how it works on iOS, but on Android apps tell OS what websites they can handle.
This does have some security implications, so there is a mechanism for web sites to vouch for an app.