It’s my understanding that if you sign up for a margin account one of the terms is that they can lend out your shares.
If you just have a cash account they can’t do it.
Also that if you have a margin account and put gtc orders on your shares, then they can’t loan them.