You misunderstood the nature of an Apple Music subscription. While subscribed you are renting the music, you are not buying it (unless you do that separately). When the subscription ends then the music disappears. This is like renting a car; when you stop renting the car has to go back to the agency.
Apple Media Services Terms and Conditions
https://www.apple.com/legal/internet-services/itunes/us/terms.html
"When your Apple Music membership ends, you will lose access to any feature of Apple Music that requires a membership, including but not limited to access to Apple Music songs stored on your device, and iCloud Music Library."
If you have missing music that you purchased, read this link:
Redownload apps, music, movies, TV shows, and books from the iTunes Store, iBooks Store, and App Store - https://support.apple.com/HT201272