Generally if you buy a phone tied up with a specific mobile network, then it is said to be the phone is locked to that specific SIM and will not work with other mobile network SIM until the contract period is over.
The contract period of such SIM locking will be around one to two years.
Now, during the contract period, if you have ported your SIM to other network, then you need to use New SIM card of the new network, and it will not work in the phone which is locked to the previous SIM.
Because, the phone is locked based on the SIM card and not on the mobile number. So, it is better to avoid SIM porting until the contract period gets over , if you want to use other SIM card in the phone.
Some users will take risk and unlock the phone using some paid services available online to unlock the phone from SIM lock.