I encountered the same problem. After the subscription in the sandbox ended, it was impossible to purchase a new one.
Solving the issue took some time… It turned out that the Grace Period feature was enabled in App Store Connect, and as stated in the documentation, during the grace period it’s not possible to purchase a subscription again.
https://developer.apple.com/documentation/storekit/reducing-involuntary-subscriber-churn