This is one of the few parts of note investing where you genuinely have to get a licensed opinion for your specific state before you buy, so budget a few hundred dollars for an attorney conversation the same way you'd budget for a title search.
Here's the mechanism, though, so you know what you're asking about. Federal debt collection law reaches people who collect debts owed to another party, and there's been real litigation and rulemaking about when a buyer of defaulted debt collecting for itself falls inside it. Separately, most states license mortgage servicing, some license debt collection agencies, and a handful license anyone who buys or holds residential mortgage loans at all. The triggers differ state by state, and some turn on whether the loan is residential, whether you're servicing it yourself, and how many loans you hold.
The practical route most small buyers take is to hire a licensed third-party servicer. The servicer does the borrower contact, the notices and the payment collection under its own licenses, which keeps you out of the direct collection role. It doesn't automatically erase every state requirement that applies to the note holder, and it does mean you own the loan and pay someone else to touch the borrower.
One thing that catches new buyers: if the loan was originated by a bank and you're the new holder, you inherit the obligation to send certain borrower notices when servicing transfers. Miss those and your foreclosure gets delayed or dismissed. Your servicer should handle it, and you should ask them in writing to confirm they will.