20 years ago it used to be the honor system. Now all the records are connected, many make it a requirement of employment to move all accounts into the firm.
Also, it's mandated by the SEC. There are obligations on you, your employer, and (if your broker is in the US) your broker to ask you, and to inform each other.
So it's kind of on the honour system - your broker probably won't ask you for payslips proving you don't work in the industry - but a lot of people are incentivized not to let it happen.