Accidentally? That requires double clicking the side button with the amount showing on the screen, followed by authorization with FaceID/Passcode. Not something that can be done accidentally. If you started a free trial, you would have seen the expiration date of the trail and the subscription price, with the message that to avoid the subscription charge, you need to cancel the trial at least 24 hours before it expires.
For that reason, most transactions in the App Store are final, but at times, Apple may provide a compassionate refund. It should never be expected though, and all you can do is try.
Request a refund for apps or content that you bought from Apple - Apple Support
To cancel a subscription:
View or cancel app subscriptions on iPhone - Apple Support