Most, but not all people who are employed have contracts which assign ownership of everything they do, including in their spare time at home on their own equipment, to their employer. And yes, a very small number of states consider such standard clauses to be unenforceable.
Most candidates who show their previous code, either written for their employer, or from side projects that are still within the scope of their contract, are violating non disclosure clauses of their contracts. Someone who has sample code to show is likely an unreliable candidate who thinks nothing of violating his signed contracts. Such candidates should not be hired.