Greetings muneeraAlangari,
Thanks for visiting the Apple Support Communities! I understand your iPhone unexpectedly turns off when you take certain actions with the device. Additionally, you mentioned your music will pause while listening to Apple Music.
I suggest checking the battery health of your iPhone, as outlined within the following support article: iPhone Battery and Performance - Apple Support
I also suggest ensuring your iPhone has the latest version of iOS, and that your apps are updated. If the behavior continues, it would then be best to contact Apple Support for additional assistance. You can see those suggestions within the following guide: If your iOS device restarts or displays the Apple logo or a spinning gear unexpectedly - Apple Support
If your songs are pausing while streaming music with Apple Music, then I suggest ensuring you have a strong network connection, and to test the behavior with a different network: Connect iPhone to the Internet - iPhone User Guide
Kind regards.