Just happened only once. A Brit sub torpedoed a German sub underwater near the end of the war.
All other sub kills have been on the surface. No other underwater sub to sub underwater kills are known.