Nope once you cancel you don’t lose your library only lose access to Apple Music content they all stay in the same places but you can’t play them without resubscribing, there has need a few periods when I’ve paused my subscription over the years and everything just comes back again when I pay.Interesting...
I had read this https://support.apple.com/en-us/118283 and thought that "cancelling" would mean losing the library.
It doesn’t cost them much to keep the database file for your library for when you return and it’s much better for customer’s satisfaction to leave it all intact.
I will admit that article definitely needs some further clarification as I definitely shared similar concerns before I did it.