a) Not all of them float. some of them sink.
b) the most logical explanation is their fat/muscle ratio. if they have lots of fat, then they float. when they're alive they keep moving around and control their depth.
c) another explanation is their swimming bladder. it is usually connected (talking about shallow water fish, deep water fish never float) to their digestive system, so they fill it with gas from their intestines. when they die they lose control over it and it fills up and floats them.