It sounds like you have a very fast closing faucet and encountered a serious case of “water hammer”, if it is for an extended time period, i.e., more than one or two bangs, then you may also have excessive pressure and the two items combined can cause damage to the piping system depending on which material it is made of.
This was the first time I heard it in the shower. I may have turned off the shower quickly. My mom showed me that it starts banging as the toilet reaches about half full and continues as the tank fills up. I have copper piping for my plumbing. Do you suggest anything?