In simple terms they pass an electric current through your body. As electric passes at different speeds through flesh and fat, it measures how long it takes to return to where it started.
They are v inaccurate though, as what you have eaten/drank in the past 12 hours or so also has a bearing on it