Convexity of the free boundary in the Stefan problem and in the dam problem