Does apple music downloads get transferred to my itunes library?

I have Apple Music, and so I download a lot of iTunes music. Does the music I download automatically get transferred to my iTunes library, do I have to sync my iPhone first before it gets transferred, or does it just stay on the phone?

I need to buy a new computer.

On the phone