Online brokerage firms and apps like Stockpile and Robinhood can give free stocks as part of their marketing initiatives. They gift new clients new stocks in hopes to have them as long-term customers. Even though they are free trading apps, they make money through from payment for order flow.