What's the function of "as" in "rainforest as animal habitats"?

Solution 1:

More girls than boys raised the idea of rainforest as (being) animal habitats.

The grammatical function here of the preposition "as" is head of the PP "as (being) animal habitats".

"of rainforest being animal habitats" is also a PP with "of" as head.

Note that prepositions can take a wide range of complements, including noun phrases and clauses.