Sometimes the gravity pulls on the moon in opposite directions. At other times, the pulling might be from similar directions. The gravitational pulling causes stresses which cause friction in the rocks. The rocks, of course, move only a little, but that is enough to generate heat. The heat may cause lava to come out, or even water, if the planet is covered with ice.
Scientists think that they have seen evidence of ice volcanoes on Titan, a moon in our solar system.
This little animated picture shows an exaggerated view of the pulling and squeezing that could result. Of course, the distortion would be much, much less. If the moon or planet were covered by a frozen ocean, ice near hot rocks might melt deep under the surface, providing liquid. If living organisms evolved here, they would live in darkness, getting warmth and chemicals from geothermal energy. Some organisms that live on geothermal energy have been found near volcanic vents deep in the oceans of the earth.