In spite of is not an idiom but a prepositional phrase. To alter (something) beyond recognition is just one of usage of the verb alter. They shold not be classified as idioms because of the following reasons:
Idiom is defined in Merriam-Webster as:
an expression that cannot be understood from the meanings of its separate words but that has a separate meaning of its own
a form of a language that is spoken in a particular area and that uses some of its own words, grammar, and pronunciations
a style or form of expression that is characteristic of a particular person, type of art, etc.
Idiom is a very-well known word, but some people don't understand what it exactly means. According to the definitions above, those expressions/forms of language/styles and forms of expression should not be written in a formal statement.
However, when it comes to mean in a broader way:
a common word or phrase with a culturally understood meaning that
differs from what its composite words' denotations would suggest.
It can be used in a formal statement. They are broadly used by many politicians and businessmen.
Here is a list of English idioms in Wikipedia. You will find many of them are very familiar to you and useful. And you will clearly see how the listed idioms are different from in spite of and to alter (something) beyond recognition.