Karolina,
Are you trying to use this code for a Work or School account or rather for a personal account and exactly what are you trying to authenticate to? Your Microsoft account or some other specific service like email, 365 (for either Work or School, or personal use instead), or some other?
Most personal account services use the 8-digit code, while those for Azure-based Work or School accounts I've seen use the 6-digit instead. So, which account you're setting up first on your device's Microsoft authenticator will typically define which of these particular codes are displayed by the authenticator, though it's possible to also set up another account as secondary, though I don't know personally how these will display because I only have a personal account myself.
Rob