In regards to a contract or other legal relationship between two parties, a third party is considered one who isn't legally bound to the given contract through any legal obligations, but still has some interest in the contract's outcome, be it financial gains or another type of benefits. Normally, the third party in a contract would have no legal rights related to that contract, though there is an exception to that rule, when the party is considered a "third party beneficiary." In this case, the third party does in fact hold some legal rights related to the contract, but they're still not as extensive as those granted to the other parties, and are usually restricted to their particular involvement in the contract.
Witnesses and others who play an auxiliary role in the closure of a contract are also considered third parties - for example, in a case when a contract is being signed and requires legal witnesses to be present, all of them are considered third parties, and of course they don't hold any legal rights to the given contract.
It should be noted that there's a difference between legal rights and legal obligations - while the third party rarely has any legal rights with regards to a contract, they're usually bound to some legal obligations related to their purpose in the contract's closure - for example, in the above example of witnesses, a witness has the legal obligation to give a testimony in court when a legal dispute arises over the contract.