Sounds like “water hammer”. If you google that others can give a way better explanation of why it happens.
I fixed mine by closing the main at the street, and opening the faucet highest and furthest from the main. In my house that was an upstairs faucet at the opposite corner from the main. Released all the pressure and then turned back on the main. Noise left and hasn’t come back for 6~ months. There are knock arresters you can install or have installed that stop the problem before it happens.