Mushrooms are actually related to anemone. They just lack the foot to move freely like that. They will release themselves from the rock if they aren't happy to find somewhere better, letting the water flow take them somewhere better. This isn't always the case in our aquariums since it'll end up flowing into a dead spot in the tank which might be a dark corner or something.