Both. Brazilian KYC/AML laws are based around the CPF number. It also serves corporations as a stable ID to identify people and track them. It's possible that it's a primary key in their databases.
For example, it's common to get cashback in stores in exchange for the CPF number. They track you, comply with regulations and reward you -- all with one government ID.
Man, seems like those two uses are self-defeating. KYC/AML, but used for things as banal as store rewards. Seems really easy to not know who the actual KYC user is then…
Until recently Brazil had no unified national ID document. Each state had theirs. It was possible to have IDs from more than one state. As the tax ID was unique for the whole country, people started using it as unique identifier of choice.
You left out the ending: now we do have an unified national ID document (under gradual adoption, it'll be a few years until it's required), and its number is that tax ID (CPF).