Modern devices have several possible audio outputs at once: built-in speakers, headphones, a monitor over HDMI, a Bluetooth headset that is still paired from yesterday. The system picks one, and if it picks the wrong one everything works perfectly — into a device you are not listening to.
This is why sound often disappears after connecting a screen or unpairing headphones. The output was switched automatically and never switched back.
Volume is also layered. There is a system level, a per-app level, and often a hardware switch or key. Any one of them at zero produces total silence while the others look fine.
Genuine hardware failure exists but is rarer, and it usually appears gradually: crackling, one channel quieter, or sound only when the cable is held at an angle.