Although there is a chance it is simply a bug only you are having, I have an idea to why this is happening.
1. Are you listening to music through headphones? If so, try another pair of headphones or play the audio through your iPhone’s speaker and see if the problem persists. I have had this problem before with a pair of headphones and it turned out it was the headphones having a faulty remote/mic control.
2. If number 1 didn’t help, make sure you are running the latest public release iOS version (iOS 11.4.1). You can check by heading to Settings > General > Software Update
3. If that didn’t help, I would suggest erasing your phone to factory settings and setting up again. Remember to make an iCloud or iTunes backup first. Details on how to do this can be found here:
Step 1: Backup - How to back up your iPhone, iPad, and iPod touch - Apple Support
Step 2: Erase - How to erase your iPhone, iPad, or iPod touch - Apple Support
4. As a last resort if all 3 suggested steps didn’t help, the best thing to do would to get on the phone with Apple and schedule a Genius Bar appointment. There is a chance there could be a hardware fault with the device which they would need to repair, or replace your device.
Hope this helps.