How to distinguish countable and uncountable nouns? How can temper be counted here?
The word "temper" itself, in this sense, isn't countable. When you qualify it with the adjective "scientific", it is countable and it is distinct from other "tempers", for example, "an unscientific temper", "a religious temper", or any number of other "tempers" that might be named.
This site discusses the use of indefinite articles with uncountable nouns:
Macmillan "uncountable with 'a'"
"... when you are qualifying or limiting the noun’s meaning in some way."
As a side note, searching for the words "scientific temper" shows that it is an expression used mostly in India. Other English-speaking countries would probably use "scientific temperament" instead, but the meaning is the same.