@Sami ******
you're confusing the misunderstood rules about entering thailand OR the rules about BUYING a visa from a thai consulate with getting an extension inside the country at the immigration office .
Inside the country you need your passport to be valid for as long as you're going to get the extension for
AND
Because you are getting a year extension in Jan 2022 which will run until Jan 2023 and your passport expires after that you're fine