There are may different small devices called “digital audio extractors” that can pull sound to/from HDMI feed and convert to/from digital optical (Toslink) or analog (traditional RCA jacks).
The actual sound from a soundbar varies greatly with the design. Some try to fully emulate 5.1 surround sound, others are more typical stereo 2.0, 3.0 or with wireless subwoofers they can provide 2.1 and 3.1
There also are few models with up-firing speakers that can provide a 5.2.1 Atmos effect.
x.y.z: x=number of main speakers, y=number of up-firing or ceiling speakers, z=number of subwoofers
2.0: Basic stereo (left and right channel)
5.1: Canonical surround sound (left, right, center, surround-left, surround-right, subwoofer)
Most common soundbars (like Sonos or other retail brands) have a built-in amplifier with a Toslink or HDMI input/output, but there are higher-end, higher-quality soundbars that are passive and have speaker binding posts to use with an external amplifier (stereo receiver).
The final result is a combination of choice of hardware, method of connection, amplifier, and adjustments to setup/configuration.
How they sound is totally subjective - really no way to determine what you like other than listening to them. Unlike displays and computers, quality is not necessarily proportional to price, but like everything else, if you pay more, you’ll most likely get a much better quality result.