The principle ties data to the reason it was gathered. People are told at collection what their information will be used for, usually in a privacy notice. Later uses are measured against that statement. A compatible further use may proceed on the original footing. An incompatible one needs a fresh basis, commonly consent, or a specific legal permission.
Compatibility is assessed by looking at the link between the old and new purposes, the context of collection and what people would reasonably expect, the nature of the data, the possible consequences for them, and the safeguards in place, which may include pseudonymization. Licensing customer or employee records to an AI lab for model training is far from the purpose of most collection, so compatibility cannot be assumed. This is why privacy notices are reviewed version by version in a data title search. Effective anonymization changes the picture, since anonymous data is outside the regulation. US laws contain related ideas, such as limits on uses that are not reasonably expected, but the tests differ.
Recording the compatibility assessment in writing is part of the accountability the GDPR expects from a controller. It also gives a buyer something to review.