Use this guide to replace a malfunctioning volume control cable—this includes the electronic switches responsible for volume up and down, and the ring/silent control.
If you're looking to replace the physical button covers, we have a guide for that too: iPhone 8 Volume and Volume Control Buttons Replacement