The direct answer to your question is that expanding foam does just that...expand. Anyone using it is responsible to be aware of that issue. For under a tub, two ideas would be (a) to use minimal expanding foam and (b) have the tub filled with water for weight until the foam is cured.
There are other, more friendly products, which can be used such as structolite.
Now....about the tub with a crack in it big enough to leak water??? We you planning to fix that with duct tape???