Individual blocks in Simscape Electrical track their own losses via an internal power_dissipated variable. For many blocks, this is calculated just based on any terms that are lossy in the equations describing the block. For example, an ideal capacitor has no intrinsic loss, while an ideal capacitor with a series resistance does. Similarly, a MOSFET has a lossy Rds,on...and there are also losses when you switch the MOSFET on with an applied Vds (because the charge on Coss gets discharged through the channel resistance).
The getPowerLossSummary function simply looks inside all of the blocks in your model and extracts the values of all of the power_dissipated variables and adds them up. If you have blocks without this variable, the function will not report any loss for that block.
Note that this feature is only supported for certain Simscape Electrical blocks. It is not supported for blocks from the Foundation Library.