Hello and welcome to iMore. Apple passcodes used to be only 4 digits until a couple of years ago when they gave us the possibility of setting up a 6 digit code. In order change to a 6 digit code, you'll need to know the current passcode.
Settings>Touch ID & Passcode>Enter existing Passcode>Change Passcode
When setting up an iPhone for the first time, you have the option of setting a 4 digit, 6 digit or alphanumeric pass phrase to unlock your iPhone. It is up to you what you choose.