I understand the skepticism and potential problems as you describe. However, for programming projects, this approach may appropriate. Consider you are in college, fresh out of bootcamp school, or self-taught coder. Lack of experience may cause difficulting landing a job. This way, you gain experience working on real-life projects even if you don't get the job.
At the same time, I doubt reputable companies would take advantage of applicants and reject completed projects just to get their work done for free.