I just had a new 50 gal electric water heater with a new 4 gal expansion tank installed. On a submersible well pump. I have hammering every time the pump kick on which happens every time any water is used. I turns on in 10-20 seconds, which causes the shower water to get cold 2 seconds after the pump kicks on and stays cold till the pump kicks off. It give you about 3 seconds of hot water till the pump kicks on again. Very hard to take a shower. I have replaced the D square 40-60 pressure switch and have the expansion tank set at 37. Not sure what else to check to stop the hammering and the cold water during the shower!
I would check the piping to the new hot water tank to make sure that the installer did not switch the cold inlet and hot outlet. What you explain suggests that the installer moved the cold water inlet to the hot water side so that when the well pump kicks on the cold water is being delivered into the hot supply piping from the tank and not into the cold inlet supply. If you could, post pictures of the tanks piping and label the pipes.