I imagine that you get to 'keep' the music as long as you maintain the subscription (which means paying for a subscription after the trial is over). The music would be unplayable without a valid subscription. Even if someone found a way to keep a copy of the files offline Apple has probably already thought of that and would require that the device phone home occasionally to check the subscription status and not allow the offline Apple Music tracks to be played until the check was done.
That being said I'm only using Apple Music for streaming and not keeping any offline copies so YMMV.