Usually a phone only gets locked for a few reasons (assuming this is like a PUK or PIN2 lock)
1. Inserting the wrong SIM for the phone (wrong carrier, aka, a Verizon SIM into an AT&T phone)
2. Attempting to bring a prepaid handset to post-paid (most in-box prepaid phones sell super cheap but depend on being activated for a month or so on the prepaid plan to pay off the subsidized cost before they'll accept a post-paid SIM)
3. Using a feature phone from who knows when, locked to Tracfone (which runs proprietary software such as their 'airtime balance display') on a non-Tracfone carrier such as AT&T.
4. Entering the SIM PIN incorrectly 3-5 times. (usually this happens because user goes to security, sees 'SIM LOCK' and hopes it's more secure than the factory screen lock, and doesn't know the original SIM PIN which it will ask for)
5. Attempting to use a 'found' phone on your own SIM, which forces remote lockout (but that usually only happens at the Google account side, and it's called 'factory reset protection' and obviously doesn't involve such a hardware lock)