If you have shown interest in a loan with a lender, they likely asked for your credit report. The credit bureaus that issued these reports will code and store your information. Any legitimate business lender can buy a list of clients that have applied for the same or similar loan products from credit reporting agencies.
Once these lenders receive your information, they will use it as a lead and send you their offer in the mail to persuade you to borrow from them. While not strictly illegal, this is still an underhanded practice, so you should avoid such offers.